diff --git a/modules/juce_core/misc/juce_WindowsRegistry.h b/modules/juce_core/misc/juce_WindowsRegistry.h index f0f79f5e98..8f1d658d32 100644 --- a/modules/juce_core/misc/juce_WindowsRegistry.h +++ b/modules/juce_core/misc/juce_WindowsRegistry.h @@ -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); diff --git a/modules/juce_core/native/juce_win32_Registry.cpp b/modules/juce_core/native/juce_win32_Registry.cpp index 2a2a37ec09..94a35eb021 100644 --- a/modules/juce_core/native/juce_win32_Registry.cpp +++ b/modules/juce_core/native/juce_win32_Registry.cpp @@ -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)