[idd] driver: add/expose CSettings read string/bool methods

This commit is contained in:
Geoffrey McRae
2026-06-03 07:07:17 +10:00
committed by Geoffrey McRae
parent 929428c273
commit a59040f0be
2 changed files with 48 additions and 1 deletions

View File

@@ -158,6 +158,51 @@ std::wstring CSettings::ReadStringValue(const wchar_t* name, const wchar_t* defa
return std::wstring(buf.data());
}
bool CSettings::ReadBoolValue(const wchar_t* name, bool defaultValue)
{
HKEY hKey = nullptr;
LONG ec = RegOpenKeyExW(
HKEY_LOCAL_MACHINE,
LGIDD_REGKEY,
0,
KEY_QUERY_VALUE,
&hKey
);
if (ec != ERROR_SUCCESS)
return defaultValue;
DWORD type = 0;
DWORD cb = 0;
ec = RegQueryValueExW(hKey, name, nullptr, &type, nullptr, &cb);
if (ec != ERROR_SUCCESS || type != REG_DWORD || cb != sizeof(DWORD))
{
RegCloseKey(hKey);
return defaultValue;
}
DWORD value = 0;
DWORD type2 = 0;
DWORD cb2 = sizeof(value);
ec = RegQueryValueExW(
hKey,
name,
nullptr,
&type2,
reinterpret_cast<LPBYTE>(&value),
&cb2
);
RegCloseKey(hKey);
if (ec != ERROR_SUCCESS || type2 != REG_DWORD || cb2 != sizeof(DWORD))
return defaultValue;
return value != 0;
}
bool CSettings::GetExtraMode(DisplayMode& mode)
{
std::wstring extraMode = ReadStringValue(L"ExtraMode", NULL);