diff --git a/libs/pbd/pbd/windows_special_dirs.h b/libs/pbd/pbd/windows_special_dirs.h index eb502c7b80..146ad747a8 100644 --- a/libs/pbd/pbd/windows_special_dirs.h +++ b/libs/pbd/pbd/windows_special_dirs.h @@ -22,6 +22,7 @@ #ifndef __libpbd_windows_special_dirs_h__ #define __libpbd_windows_special_dirs_h__ +#include #include #include "pbd/libpbd_visibility.h" @@ -38,7 +39,11 @@ namespace PBD { */ LIBPBD_API std::string get_win_special_folder_path (int csidl); -LIBPBD_API bool windows_query_registry (const char *regkey, const char *regval, std::string &rv); +/** + * Convenience function to query registry keys. Test for both native, + * as well as WindowsOnWindows 64/32 key and returns the value as UTF-8 string. + */ +LIBPBD_API bool windows_query_registry (const char* regkey, const char* regval, std::string &rv, HKEY root = HKEY_LOCAL_MACHINE); } diff --git a/libs/pbd/windows_special_dirs.cc b/libs/pbd/windows_special_dirs.cc index 4c2680054c..388dc7a67d 100644 --- a/libs/pbd/windows_special_dirs.cc +++ b/libs/pbd/windows_special_dirs.cc @@ -49,13 +49,13 @@ PBD::get_win_special_folder_path (int csidl) } bool -PBD::windows_query_registry (const char *regkey, const char *regval, std::string &rv) +PBD::windows_query_registry (const char *regkey, const char *regval, std::string &rv, HKEY root) { HKEY key; DWORD size = PATH_MAX; char tmp[PATH_MAX+1]; - if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ, &key)) + if ( (ERROR_SUCCESS == RegOpenKeyExA (root, regkey, 0, KEY_READ, &key)) && (ERROR_SUCCESS == RegQueryValueExA (key, regval, 0, NULL, reinterpret_cast(tmp), &size)) ) { @@ -63,7 +63,7 @@ PBD::windows_query_registry (const char *regkey, const char *regval, std::string return true; } - if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ | KEY_WOW64_32KEY, &key)) + if ( (ERROR_SUCCESS == RegOpenKeyExA (root, regkey, 0, KEY_READ | KEY_WOW64_32KEY, &key)) && (ERROR_SUCCESS == RegQueryValueExA (key, regval, 0, NULL, reinterpret_cast(tmp), &size)) ) {