优化一些东西

This commit is contained in:
snltty
2023-11-25 16:25:24 +08:00
parent 8e7d56c3b2
commit c46e5a8114

View File

@@ -25,7 +25,7 @@ namespace cmonitor.server.client.reports.system
drives = WindowsDrive.GetAllDrives(); drives = WindowsDrive.GetAllDrives();
registryKeys = registryOptionHelper.GetKeys(); registryKeys = registryOptionHelper.GetKeys();
ReportTask(); 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; int registryUpdateFlag = 1;
public bool RegistryOptions(RegistryUpdateInfo registryUpdateInfo) public bool RegistryOptions(RegistryUpdateInfo registryUpdateInfo)
{ {
Interlocked.Exchange(ref registryUpdated, 1); bool result = registryOptionHelper.UpdateValue(registryUpdateInfo.Name, registryUpdateInfo.Value);
return registryOptionHelper.UpdateValue(registryUpdateInfo.Name, registryUpdateInfo.Value); if (result)
{
Interlocked.Exchange(ref registryUpdated, 1);
}
return result;
} }
private void RegistryForce() private void RegistryForce()
{ {
@@ -191,9 +195,13 @@ namespace cmonitor.server.client.reports.system
{ {
continue; 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; return false;
} }