diff --git a/src/common/ManagedTelemetry/Telemetry/DataDiagnosticsSettings.cs b/src/common/ManagedTelemetry/Telemetry/DataDiagnosticsSettings.cs index 0a9aa7c891..0a537e8991 100644 --- a/src/common/ManagedTelemetry/Telemetry/DataDiagnosticsSettings.cs +++ b/src/common/ManagedTelemetry/Telemetry/DataDiagnosticsSettings.cs @@ -20,16 +20,16 @@ namespace Microsoft.PowerToys.Telemetry try { registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsRegistryValueName, 0); + + if (registryValue is not null) + { + return (int)registryValue == 1 ? true : false; + } } catch { } - if (registryValue is not null) - { - return (int)registryValue == 1 ? true : false; - } - return false; } diff --git a/src/common/SettingsAPI/settings_helpers.cpp b/src/common/SettingsAPI/settings_helpers.cpp index 25d9719a66..ad17c36caf 100644 --- a/src/common/SettingsAPI/settings_helpers.cpp +++ b/src/common/SettingsAPI/settings_helpers.cpp @@ -174,9 +174,8 @@ namespace PTSettingsHelper return; } - const bool value = enabled; - const size_t buf_size = sizeof(bool); - if (RegSetValueExW(key, DataDiagnosticsRegValueName, 0, REG_QWORD, reinterpret_cast(&value), buf_size) != ERROR_SUCCESS) + const DWORD value = enabled ? 1 : 0; + if (RegSetValueExW(key, DataDiagnosticsRegValueName, 0, REG_DWORD, reinterpret_cast(&value), sizeof(value)) != ERROR_SUCCESS) { RegCloseKey(key); return;