Hallo,
jetzt klappt es.
Ich habe folgende Procedure verwendet:
procedure TForm1.Killprocess(Name:String);
var
PEHandle,hproc: cardinal;
PE: ProcessEntry32;
begin
//NTSetPrivilege(SE_DEBUG_NAME,True);
PEHandle := CreateTOOLHelp32Snapshot(TH32cs_Snapprocess,0);
if PEHandle <> Invalid_Handle_Value then
begin
PE.dwSize := Sizeof(ProcessEntry32);
Process32first(PEHandle,
PE);
repeat
if Lowercase(
PE.szExeFile) = Lowercase(Pchar(Name)) then
begin
hproc := openprocess(Process_Terminate,false,
pe.th32Process ID);
TerminateProcess(hproc,0);
closehandle(hproc);
end;
until Process32next(PEHandle,
PE)=false;
end;
closehandle(PEHandle);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
Killprocess ( 'notepad.exe');
end;