1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-09 23:34:20 +00:00

Added a wow64 registry function.

This commit is contained in:
jules 2012-12-27 20:48:19 +00:00
parent 234525aef9
commit 83b1284d93
2 changed files with 26 additions and 13 deletions

View file

@ -80,6 +80,9 @@ public:
/** Returns true if the given value exists in the registry. */
static bool valueExists (const String& regValuePath);
/** Returns true if the given value exists in the registry. */
static bool valueExistsWow64 (const String& regValuePath);
/** Deletes a registry value. */
static void deleteValue (const String& regValuePath);

View file

@ -112,6 +112,23 @@ struct RegistryKeyWrapper
return defaultValue;
}
static bool valueExists (const String& regValuePath, const DWORD wow64Flags)
{
const RegistryKeyWrapper key (regValuePath, false, wow64Flags);
if (key.key == 0)
return false;
unsigned char buffer [512];
unsigned long bufferSize = sizeof (buffer);
DWORD type = 0;
const LONG result = RegQueryValueEx (key.key, key.wideCharValueName,
0, &type, buffer, &bufferSize);
return result == ERROR_SUCCESS || result == ERROR_MORE_DATA;
}
HKEY key;
const wchar_t* wideCharValueName;
String valueName;
@ -134,6 +151,11 @@ String WindowsRegistry::getValueWow64 (const String& regValuePath, const String&
return RegistryKeyWrapper::getValue (regValuePath, defaultValue, 0x100 /*KEY_WOW64_64KEY*/);
}
bool WindowsRegistry::valueExistsWow64 (const String& regValuePath)
{
return RegistryKeyWrapper::valueExists (regValuePath, 0x100 /*KEY_WOW64_64KEY*/);
}
bool WindowsRegistry::setValue (const String& regValuePath, const String& value)
{
return RegistryKeyWrapper::setValue (regValuePath, REG_SZ, value.toWideCharPointer(),
@ -157,19 +179,7 @@ bool WindowsRegistry::setValue (const String& regValuePath, const MemoryBlock& v
bool WindowsRegistry::valueExists (const String& regValuePath)
{
const RegistryKeyWrapper key (regValuePath, false, 0);
if (key.key == 0)
return false;
unsigned char buffer [512];
unsigned long bufferSize = sizeof (buffer);
DWORD type = 0;
const LONG result = RegQueryValueEx (key.key, key.wideCharValueName,
0, &type, buffer, &bufferSize);
return result == ERROR_SUCCESS || result == ERROR_MORE_DATA;
return RegistryKeyWrapper::valueExists (regValuePath, 0);
}
void WindowsRegistry::deleteValue (const String& regValuePath)