Killtask ! Programm beenden ! Hilfe
Hallo Leute,
hier eine Funktion zum Beenden eines Programmes !
( Direkt aus dem Task Manager )
Fragt mich net ich versteh sie auch net
Was ich jetzt aber brauch ist ne Funktion oder Procedure die klärt ob ein Proggie noch aktiv ist !
WEis jemand da n idee ?
mfg
f4r
hier eine Funktion zum Beenden eines Programmes !
( Direkt aus dem Task Manager )
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
function KillTask(ExeFileName: string): Integer;
const
PROCESS_TERMINATE = $0001;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
Result := 0;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while Integer(ContinueLoop) <> 0 do
begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
UpperCase(ExeFileName))) then
Result := Integer(TerminateProcess(
OpenProcess(PROCESS_TERMINATE,
BOOL(0),
FProcessEntry32.th32ProcessID),
0));
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
|
Fragt mich net ich versteh sie auch net
Was ich jetzt aber brauch ist ne Funktion oder Procedure die klärt ob ein Proggie noch aktiv ist !
WEis jemand da n idee ?
mfg
f4r
Für die, die es noch nicht kennen. Das Alphabet: A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
Das umzuschreiben ist nur 5 Zeilen Code löschen und eine halbe Zeile zuschreiben - nicht besonders schwer: 
Das fragt man dann über If CheckTask('meinexe.exe') Then ... ab

|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
function CheckTask(ExeFileName: string): Boolean;
var
ContinueLoop: BOOL;
FSnapshotHandle: THandle;
FProcessEntry32: TProcessEntry32;
begin
Result := False;
FSnapshotHandle := CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
FProcessEntry32.dwSize := SizeOf(FProcessEntry32);
ContinueLoop := Process32First(FSnapshotHandle, FProcessEntry32);
while Integer(ContinueLoop) <> 0 do
begin
if ((UpperCase(ExtractFileName(FProcessEntry32.szExeFile)) =
UpperCase(ExeFileName)) or (UpperCase(FProcessEntry32.szExeFile) =
UpperCase(ExeFileName))) then begin Result := True; break; end;
ContinueLoop := Process32Next(FSnapshotHandle, FProcessEntry32);
end;
CloseHandle(FSnapshotHandle);
end;
|
Das fragt man dann über If CheckTask('meinexe.exe') Then ... ab
...


