Skip to content

Commit

Permalink
cpp: Fix obtaining reg value
Browse files Browse the repository at this point in the history
  • Loading branch information
stefansjfw committed Aug 14, 2024
1 parent 2b87eff commit 60cee1d
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
26 changes: 13 additions & 13 deletions installer/PowerToysSetupCustomActions/CustomAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,25 +51,25 @@ inline bool isDataDiagnosticEnabled()
{
HKEY key{};
if (RegOpenKeyExW(HKEY_CURRENT_USER,
DataDiagnosticsRegKey,
0,
KEY_READ,
&key) != ERROR_SUCCESS)
DataDiagnosticsRegKey,
0,
KEY_READ,
&key) != ERROR_SUCCESS)
{
return false;
}

bool isDataDiagnosticsEnabled;
DWORD boolSize = static_cast<DWORD>(sizeof(bool));
DWORD isDataDiagnosticsEnabled = 0;
DWORD size = sizeof(isDataDiagnosticsEnabled);

if (RegGetValueW(
key,
DataDiagnosticsRegValueName,
nullptr,
RRF_RT_REG_QWORD,
nullptr,
&isDataDiagnosticsEnabled,
&boolSize) != ERROR_SUCCESS)
HKEY_CURRENT_USER,
DataDiagnosticsRegKey,
DataDiagnosticsRegValueName,
RRF_RT_REG_DWORD,
nullptr,
&isDataDiagnosticsEnabled,
&size) != ERROR_SUCCESS)
{
RegCloseKey(key);
return false;
Expand Down
12 changes: 6 additions & 6 deletions src/common/Telemetry/TraceBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,17 +39,17 @@ class TraceBase
return false;
}

bool isDataDiagnosticsEnabled;
DWORD boolSize = static_cast<DWORD>(sizeof(bool));
DWORD isDataDiagnosticsEnabled = 0;
DWORD size = sizeof(isDataDiagnosticsEnabled);

if (RegGetValueW(
key,
HKEY_CURRENT_USER,
DataDiagnosticsRegKey,
DataDiagnosticsRegValueName,
nullptr,
RRF_RT_REG_QWORD,
RRF_RT_REG_DWORD,
nullptr,
&isDataDiagnosticsEnabled,
&boolSize) != ERROR_SUCCESS)
&size) != ERROR_SUCCESS)
{
RegCloseKey(key);
return false;
Expand Down

0 comments on commit 60cee1d

Please sign in to comment.