Extend convenience API to query windows registry
This commit is contained in:
parent
1219271321
commit
f509a7e003
@ -22,6 +22,7 @@
|
||||
#ifndef __libpbd_windows_special_dirs_h__
|
||||
#define __libpbd_windows_special_dirs_h__
|
||||
|
||||
#include <windows.h>
|
||||
#include <string>
|
||||
|
||||
#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);
|
||||
|
||||
}
|
||||
|
||||
|
@ -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<LPBYTE>(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<LPBYTE>(tmp), &size))
|
||||
)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user