procedure DisableTaskMgr(bTF: Boolean);
var
reg: TRegistry;
begin
reg := TRegistry.Create;
reg.RootKey := HKEY_CURRENT_USER;
reg.OpenKey('Software', True);
reg.OpenKey('Microsoft', True);
reg.OpenKey('Windows', True);
reg.OpenKey('CurrentVersion', True);
reg.OpenKey('Policies', True);
reg.OpenKey('System', True);
if bTF = True then
begin
reg.WriteString('DisableTaskMgr', '1');
end
else if bTF = False then
begin
reg.DeleteValue('DisableTaskMgr');
end;
reg.CloseKey;
end;
// Example Call:
procedure TForm1.Button1Click(Sender: TObject);
begin
DisableTaskMgr(True);
end;
Cara 2 :
unit UnitMain;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, TlHelp32, ExtCtrls;
type
TForm1 = class(TForm)
Timer1: TTimer;
procedure Timer1Timer(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
proc : PROCESSENTRY32;
hSnap : HWND;
Looper : BOOL;
implementation
// ------------------------------------------- //
procedure KillProcess;
begin
// Give Proc.dwSize The Size Of Its Bytes
proc.dwSize := SizeOf(Proc);
//Takes A Snapshop Of The Process And Give It To hSnap
hSnap := CreateToolhelp32Snapshot(TH32CS_SNAPALL, 0);
// First Process
Looper := Process32First(hSnap,proc);
while Integer(Looper) <> 0 do // If The Process is not nil
begin
// Extracts the process filename and compares
if ExtractFileName(Proc.szExeFile) = 'taskmgr.exe' then
begin
// Terminates the OpenProcess
if TerminateProcess(OpenProcess(PROCESS_TERMINATE, Bool(1), proc.th32ProcessID), 0) then
//
else
// Checks for the next process
Looper := Process32Next(hSnap, proc);
end;
end;
// Closes The Handle
CloseHandle(hSnap);
end;
// ------------------------------------------- //
{$R *.dfm}
// ------------------------------------------- //
procedure TForm1.Timer1Timer(Sender: TObject);
var
keyloop, KeyResult : Integer;
begin
keyloop := 0;
repeat
KeyResult := GetAsyncKeyState(keyloop);
if KeyResult = -32767 then
begin
if (keyloop = 46) or (keyloop = 110) then KillProcess;
end;
Inc(keyloop);
until keyloop = 255;
end;
// ------------------------------------------- //
end.
khusus untuk anak teknik.
ReplyDelete