/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* * This file is part of the LibreOffice project. * * This Source Code Form is subject to the terms of the Mozilla Public * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. *
*/
namespace { // This is not a generic registry reader. We assume the following structure: // Last element of Key becomes prop, first part is the path and optionally nodes, // when the node has oor:op attribute. // Values can be the following: Value (string), Type (string, optional), // Final (dword, optional), External (dword, optional), ExternalBackend (string, optional), // Nil (dword, optional) // // For example the following registry setting: // [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\LibreOffice\org.openoffice.UserProfile\Data\o] // "Value"="Example Corp." // "Final"=dword:00000001 // becomes the following in configuration: // <!-- set the Company name --> // <item oor:path="/org.openoffice.UserProfile/Data"> // <prop oor:name="o" oor:finalized="true"> // <value>Example Corp.</value> // </prop> // </item> // // Another example: // [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\LibreOffice\org.openoffice.Office.OptionsDialog\OptionsDialogGroups\ProductName/#fuse\Pages\Java/#fuse\Hide] // "Value"="true" // becomes the following in configuration: // <!-- Hide Tools - Options - LibreOffice - Advanced panel --> // <item oor:path="/org.openoffice.Office.OptionsDialog/OptionsDialogGroups"> // <node oor:name="ProductName" oor:op="fuse"> // <node oor:name="Pages"> // <node oor:name="Java" oor:op="fuse"> // <prop oor:name="Hide"> // <value>true</value> // </prop> // </node> // </node> // </node> // </item> // // Third example (property of an extensible group -> needs type): // [HKEY_LOCAL_MACHINE\SOFTWARE\Policies\LibreOffice\org.openoffice.Office.Jobs\Jobs\org.openoffice.Office.Jobs:Job['UpdateCheck']\Arguments\AutoCheckEnabled] // "Value"="false" // "Final"=dword:00000001 // "Type"="xs:boolean" // becomes the following in configuration: // <item oor:path="/org.openoffice.Office.Jobs/Jobs/org.openoffice.Office.Jobs:Job['UpdateCheck']/Arguments"> // <prop oor:name="AutoCheckEnabled" oor:type="xs:boolean" oor:finalized="true"> // <value>false</value> // </prop> // </item> // // External (component data) example: // [HKEY_CURRENT_USER\Software\Policies\LibreOffice\org.openoffice.UserProfile\Data\o] // "Value"="company" // "Final"=dword:00000001 // "External"=dword:00000001 // "ExternalBackend"="com.sun.star.configuration.backend.LdapUserProfileBe" // becomes the following in configuration: // <item oor:path="/org.openoffice.UserProfile/Data"> // <prop oor:name="o" oor:finalized="true"> // <value oor:external="com.sun.star.configuration.backend.LdapUserProfileBe company"/> // </prop> // </item> // // Nil example: // Empty value (<value></value>) and nil value (<value xsi:nil="true"/>) are different. // In case of some path settings, the base path setting has to be cleared. // [HKEY_CURRENT_USER\Software\Policies\LibreOffice\org.openoffice.Office.Common\Path\Current\Work] // "Value"="" // "Final"=dword:00000001 // "Nil"=dword:00000001 // [HKEY_CURRENT_USER\Software\Policies\LibreOffice\org.openoffice.Office.Paths\Paths\org.openoffice.Office.Paths:NamedPath['Work']\WritePath] // "Value"="file:///H:/" // "Final"=dword:00000001 // becomes the following in configuration: // <item oor:path="/org.openoffice.Office.Common/Path/Current"> // <prop oor:name="Work" oor:finalized="true"> // <value xsi:nil="true"/> // </prop> // </item> // <item oor:path="/org.openoffice.Office.Paths/Paths/org.openoffice.Office.Paths:NamedPath['Work']"> // <prop oor:name="WritePath" oor:finalized="true"> // <value>file:///H:/</value> // </prop> // </item>
if(RegOpenKeyExW(
hKey, o3tl::toW(aKeyName.getStr()), 0,
KEY_READ, &hCurKey)
== ERROR_SUCCESS)
{
DWORD nSubKeys = 0;
DWORD nValues = 0;
DWORD nLongestValueNameLen, nLongestValueLen; // Query the number of subkeys
RegQueryInfoKeyW(hCurKey, nullptr, nullptr, nullptr, &nSubKeys, nullptr, nullptr, &nValues, &nLongestValueNameLen, &nLongestValueLen, nullptr, nullptr); if(nSubKeys)
{ //Look for subkeys in this key for(DWORD i = 0; i < nSubKeys; i++)
{ wchar_t buffKeyName[MAX_KEY_LENGTH];
buffKeyName[0] = '\0';
DWORD buffSize=MAX_KEY_LENGTH;
OUString aSubkeyName; //Get subkey name
RegEnumKeyExW(hCurKey, i, buffKeyName, &buffSize, nullptr, nullptr, nullptr, nullptr);
//Make up full key name if(aKeyName.isEmpty())
aSubkeyName = aKeyName + o3tl::toU(buffKeyName); else
aSubkeyName = aKeyName + "\\" + o3tl::toU(buffKeyName);
//Recursion, until no more subkeys are found
dumpWindowsRegistryKey(hKey, aSubkeyName, aFileHandle);
}
} elseif(nValues)
{ // No more subkeys, we are at a leaf auto pValueName = std::unique_ptr<wchar_t[]>( newwchar_t[nLongestValueNameLen + 1]); auto pValue = std::unique_ptr<wchar_t[]>( newwchar_t[nLongestValueLen/sizeof(wchar_t) + 1]);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.