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;
No comments:
Post a Comment