diff --git a/installer/PowerToysSetupCustomActions/CustomAction.cpp b/installer/PowerToysSetupCustomActions/CustomAction.cpp index de2aa770f7d..3f6834ef7cd 100644 --- a/installer/PowerToysSetupCustomActions/CustomAction.cpp +++ b/installer/PowerToysSetupCustomActions/CustomAction.cpp @@ -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(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; diff --git a/src/common/Telemetry/TraceBase.h b/src/common/Telemetry/TraceBase.h index 065c25a5c5b..da722bb4574 100644 --- a/src/common/Telemetry/TraceBase.h +++ b/src/common/Telemetry/TraceBase.h @@ -39,17 +39,17 @@ class TraceBase return false; } - bool isDataDiagnosticsEnabled; - DWORD boolSize = static_cast(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;