Browse Source

Added a wow64 registry function.

tags/2021-05-28
jules 13 years ago
parent
commit
83b1284d93
2 changed files with 26 additions and 13 deletions
  1. +3
    -0
      modules/juce_core/misc/juce_WindowsRegistry.h
  2. +23
    -13
      modules/juce_core/native/juce_win32_Registry.cpp

+ 3
- 0
modules/juce_core/misc/juce_WindowsRegistry.h 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);


+ 23
- 13
modules/juce_core/native/juce_win32_Registry.cpp 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)


Loading…
Cancel
Save