mirror of
https://github.com/gnif/LookingGlass.git
synced 2026-06-07 07:14:27 +00:00
[idd] driver: add/expose CSettings read string/bool methods
This commit is contained in:
committed by
Geoffrey McRae
parent
929428c273
commit
a59040f0be
@@ -158,6 +158,51 @@ std::wstring CSettings::ReadStringValue(const wchar_t* name, const wchar_t* defa
|
|||||||
return std::wstring(buf.data());
|
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)
|
bool CSettings::GetExtraMode(DisplayMode& mode)
|
||||||
{
|
{
|
||||||
std::wstring extraMode = ReadStringValue(L"ExtraMode", NULL);
|
std::wstring extraMode = ReadStringValue(L"ExtraMode", NULL);
|
||||||
|
|||||||
@@ -43,9 +43,11 @@ class CSettings
|
|||||||
bool GetExtraMode(DisplayMode & mode);
|
bool GetExtraMode(DisplayMode & mode);
|
||||||
unsigned GetDefaultRefresh() const;
|
unsigned GetDefaultRefresh() const;
|
||||||
|
|
||||||
|
std::wstring ReadStringValue(const wchar_t* name, const wchar_t* defaultValue);
|
||||||
|
bool ReadBoolValue(const wchar_t* name, bool defaultValue);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
DisplayModes m_displayModes;
|
DisplayModes m_displayModes;
|
||||||
std::wstring ReadStringValue(const wchar_t* name, const wchar_t* default);
|
|
||||||
|
|
||||||
bool ReadModesValue(std::vector<std::wstring> &out) const;
|
bool ReadModesValue(std::vector<std::wstring> &out) const;
|
||||||
bool ParseModeString(const std::wstring& in, DisplayMode& out);
|
bool ParseModeString(const std::wstring& in, DisplayMode& out);
|
||||||
|
|||||||
Reference in New Issue
Block a user