Function KillTask (ExefileName: String): Integer;
Const
Process_terminate = $ 0001;
VAR
Continueloop: bool;
Fsnapshothandle: thandle;
FPROCESSENTRY32: TPROCESSENTRY32;
Begin
Result: = 0;
Fsnapshothandle: = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);
FPROCESSSENTRY32.DWSIZE: = SIZEOF (fProcesSsentry32);
Continueloop: = process32first (fsnapshothandle, fprocessentry32);
While Integer (Continueloop) <> 0 DO
Begin
IF ((Uppercase (fProcesSsentry32.szexefile) =
Uppercase (exefilename))
OR (Uppercase (fProcesSsentry32.szexefile) =
Uppercase (exefilename))).
Result: = INTEGER (TerminateProcess "
Process_Terminate, Bool (0),
FPROCESSENTRY32.TH32PROCESSID, 0));
Continueloop: = process32next (fsnapshothandle, fprocesstry32);
END;
END;