实现效果:
知识运用:
注册表项中的NoClose键进行设置
实现代码:
private void button1_Click(object sender, EventArgs e) { RegistryKey rk = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"); rk.SetValue("NoClose",1); MessageBox.Show("屏蔽关机功能成功"); } private void button2_Click(object sender, EventArgs e) { RegistryKey rk = Registry.CurrentUser.CreateSubKey(@"Software\Microsoft\Windows\CurrentVersion\Policies\Explorer"); rk.SetValue("NoClose", 0); MessageBox.Show("开启关机功能成功,重新启动生效"); }