--> Replace / replace Task Manager with your program or replace with any program you want with delphi | Delphi Tips Trick

For Newbie

Tuesday, 15 November 2011

Replace / replace Task Manager with your program or replace with any program you want with delphi

| Tuesday, 15 November 2011

Declaration procedure:
const
   xKey = 'SOFTWARE \ Microsoft \ Windows NT \ CurrentVersion \ Image File Execution Options \ taskmgr.exe';

/ / Procedure to replace the Task Manager
ReplaceTaskManagerWith procedure (FTarget: TFileName);
begin
   with TRegistry.Create do
   begin
     RootKey: = HKEY_LOCAL_MACHINE;
     try
       OpenKey (xKey, True);
       WriteString ('Debugger', FTarget);
     finally
       free;
     end;
   end;
end;

/ / Procedure Task Manager in order to return to his native habitat
SetTaskManagerNormal procedure;
begin
   with TRegistry.Create do
   begin
     RootKey: = HKEY_LOCAL_MACHINE;
     try
       if OpenKey (xKey, False) then DeleteValue ('debugger');
     finally
       free;
     end;
   end;
end;

Example of implementation:
Replacing Task Manager with your program:
procedure TForm1.Button1Click (Sender: TObject);
begin
   ReplaceTaskManagerWith (Application.ExeName);
end;

Next, replace Task Manager with other programs, eg: Notepad:
procedure TForm1.Button1Click (Sender: TObject);
begin
   ReplaceTaskManagerWith ('notepad');
end;

Task Manager back to the habitat of origin (default config):
procedure TForm1.Button2Click (Sender: TObject);
begin
   SetTaskManagerNormal;
end;

Related Posts

No comments: