How do I block task Manager with C # code?

Source: Internet
Author: User

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?

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.