Although the desktop lock screen software I made in the past also disabled the task manager, it adopted a relatively stupid method and was also harmful to the operating system. Because task management is also a form, it is also an independent process, so you only need to forcefully close this process to close the task manager. The process name of the task management is "taskmgr". In the program, a separate timer is used to traverse all processes opened by the system every 100 milliseconds. If the name of the process appears, it will be closed directly if the name of the process is the same as the name of the task manager. This can indirectly disable task management, but this method cannot be used frequently. If the task management process is often forced to shut down, the operating system's message processing will be chaotic. Therefore, the desktop management software I wrote at that time was not really practical.
The principle of disabling task management in this time is to directly modify the system's registry to achieve the purpose of disabling the task manager. Modify the registry key of the task manager as:
HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\System
Add a key to this item: DisableTaskmgr. When the value is 1, the task manager is disabled. When the value is 0, the task manager is enabled. My computer does not have the system item by default.
The above principle has been introduced, and the following will list the code for how to implement this function using C#.
/// <summary>
/// Methods to manage task manager
/// </summary>
/// <param name="arg">0: Enable Task Manager 1: Disable Task Manager</param>
private void ManageTaskManager(int arg)
{
RegistryKey currentUser = ;
RegistryKey system = (@"Software\Microsoft\Windows\CurrentVersion\Policies\System",true );
//Create this item if the system item does not exist
if (system == null)
{
system = (@"Software\Microsoft\Windows\CurrentVersion\Policies\System");
}
("DisableTaskmgr", arg, );
();
}
By using this method, you can disable the task manager in the program.
Also remember to add the following quotes:
Microsoft.Win32;