[runner]Fix crashes caused by wrong setting AllowDataDiagnostics registry value (#37015)
* Fix setting registry value * Prevent future similar crashes
This commit is contained in:
Родитель
422096b907
Коммит
b6b941c55b
|
@ -20,15 +20,15 @@ namespace Microsoft.PowerToys.Telemetry
|
|||
try
|
||||
{
|
||||
registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsRegistryValueName, 0);
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
if (registryValue is not null)
|
||||
{
|
||||
return (int)registryValue == 1 ? true : false;
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -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<const BYTE*>(&value), buf_size) != ERROR_SUCCESS)
|
||||
const DWORD value = enabled ? 1 : 0;
|
||||
if (RegSetValueExW(key, DataDiagnosticsRegValueName, 0, REG_DWORD, reinterpret_cast<const BYTE*>(&value), sizeof(value)) != ERROR_SUCCESS)
|
||||
{
|
||||
RegCloseKey(key);
|
||||
return;
|
||||
|
|
Загрузка…
Ссылка в новой задаче