aboutsummaryrefslogtreecommitdiff
path: root/WinUtils.h
diff options
context:
space:
mode:
Diffstat (limited to 'WinUtils.h')
-rw-r--r--WinUtils.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/WinUtils.h b/WinUtils.h
index d020727..4f544a1 100644
--- a/WinUtils.h
+++ b/WinUtils.h
@@ -79,6 +79,19 @@ inline std::string RegGetString(HKEY hKey, LPCSTR sValue, const std::string& str
return strDef;
}
+inline std::string RegGetString(HKEY hKey, LPCSTR sSubKey, LPCSTR sValue, const std::string& strDef)
+{
+ CHAR buf[1024];
+ DWORD len = (ARRAYSIZE(buf) - 1) * sizeof(CHAR);
+ if (RegGetValueA(hKey, sSubKey, sValue, RRF_RT_REG_SZ, nullptr, buf, &len) == ERROR_SUCCESS)
+ {
+ buf[len / sizeof(CHAR)] = TEXT('\0');
+ return buf;
+ }
+ else
+ return strDef;
+}
+
inline std::tstring RegGetString(HKEY hKey, LPCWSTR sValue, const std::tstring& strDef)
{
WCHAR buf[1024];
@@ -92,6 +105,19 @@ inline std::tstring RegGetString(HKEY hKey, LPCWSTR sValue, const std::tstring&
return strDef;
}
+inline std::tstring RegGetString(HKEY hKey, LPCWSTR sSubKey, LPCWSTR sValue, const std::tstring& strDef)
+{
+ WCHAR buf[1024];
+ DWORD len = (ARRAYSIZE(buf) - 1) * sizeof(WCHAR);
+ if (RegGetValueW(hKey, sSubKey, sValue, RRF_RT_REG_SZ, nullptr, buf, &len) == ERROR_SUCCESS)
+ {
+ buf[len / sizeof(WCHAR)] = TEXT('\0');
+ return buf;
+ }
+ else
+ return strDef;
+}
+
inline DWORD RegGetDWORD(HKEY hKey, LPCTSTR sValue, DWORD dwDef)
{
DWORD data = 0;