mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 15:25:01 +01:00
Consolidate code: add library method to query Windows registry
This commit is contained in:
parent
5d193f7638
commit
8852069ead
2 changed files with 28 additions and 0 deletions
|
|
@ -38,6 +38,8 @@ namespace PBD {
|
||||||
*/
|
*/
|
||||||
LIBPBD_API std::string get_win_special_folder_path (int csidl);
|
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);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* __libpbd_windows_special_dirs_h__ */
|
#endif /* __libpbd_windows_special_dirs_h__ */
|
||||||
|
|
|
||||||
|
|
@ -20,6 +20,7 @@
|
||||||
#include <shlobj.h>
|
#include <shlobj.h>
|
||||||
#include <winreg.h>
|
#include <winreg.h>
|
||||||
#include <glib.h>
|
#include <glib.h>
|
||||||
|
#include "shlobj.h"
|
||||||
|
|
||||||
#include "pbd/windows_special_dirs.h"
|
#include "pbd/windows_special_dirs.h"
|
||||||
|
|
||||||
|
|
@ -47,3 +48,28 @@ PBD::get_win_special_folder_path (int csidl)
|
||||||
return std::string();
|
return std::string();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
PBD::windows_query_registry (const char *regkey, const char *regval, std::string &rv)
|
||||||
|
{
|
||||||
|
HKEY key;
|
||||||
|
DWORD size = PATH_MAX;
|
||||||
|
char tmp[PATH_MAX+1];
|
||||||
|
|
||||||
|
if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ, &key))
|
||||||
|
&& (ERROR_SUCCESS == RegQueryValueExA (key, regval, 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
rv = Glib::locale_to_utf8 (tmp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( (ERROR_SUCCESS == RegOpenKeyExA (HKEY_LOCAL_MACHINE, regkey, 0, KEY_READ | KEY_WOW64_32KEY, &key))
|
||||||
|
&& (ERROR_SUCCESS == RegQueryValueExA (key, regval, 0, NULL, reinterpret_cast<LPBYTE>(tmp), &size))
|
||||||
|
)
|
||||||
|
{
|
||||||
|
rv = Glib::locale_to_utf8 (tmp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue