From c46e5a8114a24c197ba4a5344586c2d8be1e074f Mon Sep 17 00:00:00 2001 From: snltty <1069410172@qq.com> Date: Sat, 25 Nov 2023 16:25:24 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=B8=80=E4=BA=9B=E4=B8=9C?= =?UTF-8?q?=E8=A5=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../client/reports/system/SystemReport.cs | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/cmonitor/server/client/reports/system/SystemReport.cs b/cmonitor/server/client/reports/system/SystemReport.cs index 357b4280..4698b844 100644 --- a/cmonitor/server/client/reports/system/SystemReport.cs +++ b/cmonitor/server/client/reports/system/SystemReport.cs @@ -25,7 +25,7 @@ namespace cmonitor.server.client.reports.system drives = WindowsDrive.GetAllDrives(); registryKeys = registryOptionHelper.GetKeys(); ReportTask(); - RegistryOptions(new RegistryUpdateInfo { Name = "SoftwareSASGeneration", Value = true }); + RegistryOptions(new RegistryUpdateInfo { Name = "SoftwareSASGeneration", Value = false }); } @@ -63,8 +63,12 @@ namespace cmonitor.server.client.reports.system int registryUpdateFlag = 1; public bool RegistryOptions(RegistryUpdateInfo registryUpdateInfo) { - Interlocked.Exchange(ref registryUpdated, 1); - return registryOptionHelper.UpdateValue(registryUpdateInfo.Name, registryUpdateInfo.Value); + bool result = registryOptionHelper.UpdateValue(registryUpdateInfo.Name, registryUpdateInfo.Value); + if (result) + { + Interlocked.Exchange(ref registryUpdated, 1); + } + return result; } private void RegistryForce() { @@ -191,9 +195,13 @@ namespace cmonitor.server.client.reports.system { continue; } - Registry.SetValue(path, pathItem.Key, int.Parse(value ? pathItem.DisallowValue : pathItem.AllowValue), RegistryValueKind.DWord); + string setValue = value ? pathItem.DisallowValue : pathItem.AllowValue; + if(Registry.GetValue(path, pathItem.Key, pathItem.AllowValue).ToString() != setValue) + { + Registry.SetValue(path, pathItem.Key, int.Parse(setValue), RegistryValueKind.DWord); + return true; + } } - return true; } return false; }