This is what I find on the Internet and add some of my own code, after my test, can block the task Manager, but there are some flaws.
First, I create a new project in vs2012, select the Window form application under window and pull the form Form1 into a test
button, set name Btntask,text to "Disable Task Manager", double-click the button btntask, enter Btntack_click
(Object o,...) {} event, the code changes the registry's Task Manager to disable and enable it as follows:
private void Btntask_click (object sender, EventArgs e)
{
Gets the text of the button
string str = This.btnTask.Text;
Read Hikey_current_user in the window registry
RegistryKey key = Registry.currentuser;
Open or create a subkey and access the
Key = key. CreateSubKey (@ "Software\microsoft\windows\currentversion\policies\system");
if (str = = "Disable Task Manager") {
Key. SetValue ("DisableTaskMgr", 1,registryvaluekind.dword);
if (MessageBox.Show ("Disabled Success") ==dialogresult.ok) {
This.btnTask.Text = "Enable Task Manager";
Refresh ();
}
}
else if (str = = "Enable Task Manager") {
Key. SetValue ("DisableTaskMgr", 0, Registryvaluekind.dword);
if (MessageBox.Show ("enable success") = = DialogResult.OK)
{
This.btnTask.Text = "Disable Task Manager";
}
}
Key. Close ();
}
How do I block task Manager with C # code?