Registriert seit: 18. Mai 2003
634 Beiträge
|
Re: Externes Programm sofort beenden (ein Spiel!)
21. Nov 2003, 14:27
Bidäschön:
Delphi-Quellcode:
var
run:boolean;
Speed:integer;
Programm:string;
procedure SetRun(Value:boolean;Rate:integer;ProgrammName:string);
var
ThreadHandle: THandle;
ThreadID: DWORD;
procedure killProgramm;
begin
while Run do
begin
sleep(Speed);
if FindWindow(NIL,PChar(Programm))<>0 then PostMessage(FindWindow(NIL,PChar(Programm)), wm_close, 1, 1);
end;
end;
begin
Speed:=Rate;
Programm:=ProgrammName;
if Run=Value then exit;
Run:=Value;
if Value then
begin
sleep(1);
ThreadHandle:=CreateThread(nil, 0, TFNThreadStartRoutine(@killProgramm),@ProgrammName, 0, ThreadID);
if ThreadHandle<>0 then CloseHandle(ThreadHandle);
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
SetRun(true,1,'Outlook Express');
end;
|
|
Zitat
|