本文介绍了如何编写代码立即生效而无需重启pc的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
private void Button10_Click(object sender, EventArgs e)
{
Counter = 60;
try
{
if (voldis.Checked)
{
RegistryKey systemRegistry = Registry.CurrentUser.CreateSubKey("\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
systemRegistry.SetValue("NoDrives", 0x3ffffff);
}
else if (volena.Checked)
{
RegistryKey systemRegistry = Registry.CurrentUser.CreateSubKey("\\Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\Explorer");
systemRegistry.SetValue("NoDrives", 0);
}
}
catch (Exception)
{
MessageBox.Show("Run this application as Admin to Enable or Disable", "@Need Administrator@");
}
DialogResult dialogResult = MessageBox.Show("PC have to reboot for effective", "Attention", MessageBoxButtons.YesNo);
if (dialogResult == DialogResult.Yes)
{
Process.Start("shutdown", "-R -t 00"); //>>>how to write a code to take immediate effect without restart pc
}
}
推荐答案
这篇关于如何编写代码立即生效而无需重启pc的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!