diff options
Diffstat (limited to 'WinUtils.h')
-rw-r--r-- | WinUtils.h | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -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; |