Saturday 27 September 2014

How to Disable Task Manager while running your WinForm Application in C#

CODE

1.start visual studio  as Administrator and create a winform Application


2. Create Two Events  i. Form_Load Event(for disable Task Manager)
                                    ii. Form_Closed  Event(for Enable task Manager)
both of those events contain a method "ShowTaskManager(boolean)" with boolean as argument
like below picture

3. Now define the Method

Add reference file i.e  "Microsoft.Win32 " dll file because we have to use RegistryKey Class
to  access  regedit tool and It's used to view and change settings in the system registry, which contains information(like a TaskManager) about how your computer runs.

4. Now you can run  application (should open this application as Administrator) and open Task Manager it will show a window  like below.
5. When you Close the application and open Task Manager then it works.




LOGIC BEHIND THIS

1.click start button
    (start)                                                                                                      (regedit tool) 

2.Type regedit then click the tool showing like above image in yellow color
3.It will open a window like below and follow 
[HKEY_CURRENT_USER\Software\Microsoft\Windows\CurrentVersion\Policies\]

4.     in this below code(define in ShowTaskManager() ) means it will create a System key(in below picture ) in policies folder 


 

5.

 When form_Load event will call "ShowTaskManager(true)" this method will invoke and call       "If  part" of this "ShowTaskManager(true)" method .

and that will create a field insight System key i.e  "DisableTaskMgr" with value "1"  means it will not appear Task Manager. 
i.e 

6.

When form_Closed event will call "ShowTaskManager(false)" this method will invoke and call       "Else  part" of this "ShowTaskManager(false)" method .

and that will  Delete System key So as previous  Task Manager.  will appear.




thank you for view my post if any query then comment  fastly . 

1 comment: