public partial class Form1 : Form
{
string message;
string localmachineKey = @"HKEY_LOCAL_MACHINE/Software/Microsoft/Windows/CurrentVersion/Policies/System";
string currentuserKey = @"HKEY_CURRENT_User/Software/Microsoft/Windows/CurrentVersion/Policies/System";
string task = @"DisableTaskMgr";
bool taskEnable;
public Form1()
{
InitializeComponent();
message = this.butTask.Text;
butTask.Text = "禁用" + message;
try
{
taskEnable = true;
string localmachineValue = Registry.GetValue(localmachineKey, task, string.Empty).ToString();
string currentuserValue = Registry.GetValue(currentuserKey, task, string.Empty).ToString();
if (localmachineValue.Equals("1") && currentuserValue.Equals("1"))
{
taskEnable = false;
butTask.Text = "启用" + message;
}
}
catch { }
}
private void butTask_Click(object sender, EventArgs e)
{
if (taskEnable)
{
Registry.SetValue(localmachineKey, task, 1);
Registry.SetValue(currentuserKey, task, 1);
MessageBox.Show(butTask.Text + "成功!");
taskEnable = false;
butTask.Text = "启用" + message;
}
else
{
Registry.SetValue(localmachineKey, task, 0);
Registry.SetValue(currentuserKey, task, 0);
MessageBox.Show(butTask.Text + "成功!");
taskEnable = true;
butTask.Text = "禁用" + message;
}
}
}
如何禁止、启用windows任务管理器
最新推荐文章于 2024-08-08 19:01:21 发布