To determine if a registry key exists:
LONG lRes = RegOpenKeyExW(HKEY_LOCAL_MACHINE, L"SOFTWARE\\Perl", 0, KEY_READ, &hKey);
if (lRes == ERROR_SUCCESS) {
// Key exists
} else if (lRes == ERROR_FILE_NOT_FOUND) {
// Key does not exist
}
To retrieve the default value of a key:
std::wstring strKeyDefaultValue;
GetStringRegKey(hKey, L"", strKeyDefaultValue, L"bad");
To retrieve a string value:
std::wstring strValueOfBinDir;
GetStringRegKey(hKey, L"BinDir", strValueOfBinDir, L"bad");
To retrieve a DWORD value:
DWORD nValue;
LONG nError = GetDWORDRegKey(hKey, L"DWORD_Value_Name", nValue, 0);
To retrieve a Boolean value:
bool bValue;
LONG nError = GetBoolRegKey(hKey, L"BOOL_Value_Name", bValue, false);
The following library dependencies are required for these functions:
Remember, these functions are for reading values only. Avoid writing to the registry if possible.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3