Delphi Tips Trick

For Newbie

Iklan Responsive Atas

LightBlog
Responsive Ads Here

Tuesday, 15 November 2011

Disable Task Manbyager Delphi




Simple tricks that are used to disable the emergence of the Task Manager in Windows XP.

Method # 1: Disable the Task Manager via System Policy.
Declaration procedure:
DisableTaskMgrBySysPol procedure (const e: Boolean);
const
   Key = "Software \ Microsoft \ Windows \ CurrentVersion \ Policies \ System ';
begin
   {"TASK MANAGER HAS BEEN DISABLED BY ADMINISTRATOR"}
   with TRegistry.Create do
   begin
     RootKey: = HKEY_CURRENT_USER;
     try
       if OpenKey (Key, True) then
         WriteBool ('DisableTaskMgr', e);
     finally
        free;
     end;
   end;
end;

Example of implementation:
procedure TForm1.Button1Click (Sender: TObject);
begin
   DisableTaskMgrBySysPol (True);
end;


Method # 2: Disable the Task Manager via Image File Execution.
Declaration procedure:
DisableTaskMgrByImageFileExec procedure (const e: Boolean);
const
   Key = 'SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \'
          'Image File Execution Options \ taskmgr.exe';
begin
   {Task Manager will not be executed}
   with TRegistry.Create do
   begin
     RootKey: = HKEY_LOCAL_MACHINE;
     try
       if OpenKey (Key, True) then
       begin
         if e then WriteString ('debugger', '')
         else DeleteValue ('debugger');
       end;
     finally
        free;
     end;
   end;
end;

Example of implementation:
procedure TForm1.Button1Click (Sender: TObject);
begin
   DisableTaskMgrByImageFileExec (True);
end;


Method # 3: Disable the Task Manager through FindWindow. This way you have to continuously monitor whether the Task Manager is active or not. You can use a timer to monitor them.
Declaration procedure:
DisableTaskMgrByWindow procedure;
var
   targetHwnd: hWnd;
begin
   / / Task Manager Window Handle
   targetHwnd: = FindWindow ('# 32770', 'Windows Task Manager');
   SendMessage (targetHwnd, WM_CLOSE, 0, 0);
end;

Example of implementation:
TForm1.Timer1Timer procedure (Sender: TObject);
begin
   DisableTaskMgrByWindow;
end;

No comments: