实现效果:
知识运用:
Registry类的SetValue方法
public static void SetValue (string keyName, string valueName, Object value)
实现代码:
private void button1_Click(object sender, EventArgs e) { Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System","DisableTaskMgr",1); Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", 1); MessageBox.Show("已成功禁止Windows任务管理器"); } private void button2_Click(object sender, EventArgs e) { Registry.SetValue(@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", 0); Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System", "DisableTaskMgr", 0); MessageBox.Show("已成功开启Windows任务管理器"); }