Previously produced desktop lock screen software Although the Task Manager has been disabled, but the use of a more stupid method, but also a certain harm to the operating system. Because task management is also a form, which is also a separate process, it is only mandatory to close the process can be closed Task Manager, the task management process name "Taskmgr", in the program with a separate timer, every 100 milliseconds to traverse the system to open all processes, Whenever the name of the process that appears is the same as the Task manager name, close directly. This can indirectly achieve the role of disabling task management, however this method can not be used frequently, if the frequently enforced shutdown task management process will be confused with the operating system message processing. So the desktop management software that was written at that time was not really practical.
This implementation of the principle of disabling task management is to directly modify the system's registry to achieve the purpose of disabling Task Manager, modify the Task Manager registry key is:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System
add a key to this key: disabletaskmgr, a value of 1 is disabled Task Manager, the value is 0 when the Task Manager is enabled, my computer does not have the system by default.
The principle is described above and the code to implement this functionality in C # is listed below.
1 /// <summary>2 3 ///How to manage Task Manager4 /// </summary>5 /// <param name= "arg" >0: Enable Task Manager 1: Disable Task Manager</param>6 Private voidManagetaskmanager (intArg)7 {8RegistryKey CurrentUser =Registry.currentuser;9RegistryKey system = Currentuser.opensubkey (@"Software\microsoft\windows\currentversion\policies\system",true );Ten //if the system item does not exist, create this item One if(System = =NULL) A { -System = Currentuser.createsubkey (@"Software\microsoft\windows\currentversion\policies\system"); - } theSystem. SetValue ("DisableTaskMgr", ARG, registryvaluekind.dword); - currentuser.close (); -}View Code
by using this method, you can disable Task Manager in your program. also remember to add the following references to the line:
Microsoft.Win32;