[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,16 +20,16 @@ namespace Microsoft.PowerToys.Telemetry
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsRegistryValueName, 0);
|
registryValue = Registry.GetValue(DataDiagnosticsRegistryKey, DataDiagnosticsRegistryValueName, 0);
|
||||||
|
|
||||||
|
if (registryValue is not null)
|
||||||
|
{
|
||||||
|
return (int)registryValue == 1 ? true : false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
if (registryValue is not null)
|
|
||||||
{
|
|
||||||
return (int)registryValue == 1 ? true : false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -174,9 +174,8 @@ namespace PTSettingsHelper
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const bool value = enabled;
|
const DWORD value = enabled ? 1 : 0;
|
||||||
const size_t buf_size = sizeof(bool);
|
if (RegSetValueExW(key, DataDiagnosticsRegValueName, 0, REG_DWORD, reinterpret_cast<const BYTE*>(&value), sizeof(value)) != ERROR_SUCCESS)
|
||||||
if (RegSetValueExW(key, DataDiagnosticsRegValueName, 0, REG_QWORD, reinterpret_cast<const BYTE*>(&value), buf_size) != ERROR_SUCCESS)
|
|
||||||
{
|
{
|
||||||
RegCloseKey(key);
|
RegCloseKey(key);
|
||||||
return;
|
return;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче