-1
我與此代碼有衝突問題,它仍然想要刪除值「StateFlags0200」或「StateFlags0300」,即使它不存在於Windows註冊表,但我的邏輯似乎對我來說是正確的。我與此代碼有衝突問題,它仍然想要刪除值
enter code here
私人無效checkBox1_CheckedChanged(對象發件人,EventArgs的)
{
#region Block #1
if ((checkBox1.Checked == true) & (radioButton1.Checked == true))
{
RegistryKey KeyBase = Registry.LocalMachine;
RegistryKey KeyPath = KeyBase.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders", true);
KeyPath.SetValue("StateFlags0100", Convert.ToInt32("2", 16), RegistryValueKind.DWord);
KeyPath.Close();
}
else
{
RegistryKey KeyBase = Registry.LocalMachine;
RegistryKey KeyPath = KeyBase.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders", true);
KeyPath.DeleteValue("StateFlags0100");
KeyPath.Close();
}
if ((checkBox1.Checked == true) & (radioButton2.Checked == true))
{
RegistryKey KeyBase = Registry.LocalMachine;
RegistryKey KeyPath = KeyBase.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders", true);
KeyPath.SetValue("StateFlags0200", Convert.ToInt32("2", 16), RegistryValueKind.DWord);
KeyPath.Close();
}
else
{
RegistryKey KeyBase = Registry.LocalMachine;
RegistryKey KeyPath = KeyBase.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders", true);
KeyPath.DeleteValue("StateFlags0200");
KeyPath.Close();
}
if ((checkBox1.Checked == true) & (radioButton3.Checked == true))
{
RegistryKey KeyBase = Registry.LocalMachine;
RegistryKey KeyPath = KeyBase.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders", true);
KeyPath.SetValue("StateFlags0300", Convert.ToInt32("2", 16), RegistryValueKind.DWord);
KeyPath.Close();
}
else
{
RegistryKey KeyBase = Registry.LocalMachine;
RegistryKey KeyPath = KeyBase.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\VolumeCaches\Active Setup Temp Folders", true);
KeyPath.DeleteValue("StateFlags0300");
KeyPath.Close();
}
#endregion
}
它可以工作,但當我從radiobutton1更改爲另一個時,它將刪除初始值。這些是我試圖製作的配置文件。在註冊表中,它不應該刪除其他「StateFlags」。 –
簡單的解決方案是創建3個選項卡,並將我的複選框與代碼中的相同名稱相同的三個複選框相加,然後刪除我的單選按鈕。會有另一種解決方案嗎? 對我英語不好的藉口。 –
它如何刪除「初始值」?我無法從上面的代碼中看到這是可能的。 –