Цитата:
Сообщение от BITCH666
а где здесь задаётся имя процесса? я не могу найти.
|
Вообще здесь в параметре процедуры, но этот пример не убьет процесс.
Вот код, который найдет PID по имени. А дальше можно и "убить" процесс.
Код:
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 28 29 30 | function GetProcessPidByName(fName: String ): THandle;
var
hSnapshot: THandle;
function ProcessPidByName(hProcess: DWord; fName: String ): THandle;
var
ProcEntry: TProcessEntry32;
ProcessPid: THandle;
begin
ProcEntry . dwSize:= SizeOf(ProcEntry);
ProcessPid:= 0 ;
if Process32First(hProcess, ProcEntry) then
begin
repeat if ProcEntry . szExeFile = fName then
begin
ProcessPid:= ProcEntry . th32ProcessID;
Result:= ProcessPid;
Exit;
end ;
until not Process32Next(hProcess, ProcEntry)
end ;
Result:= ProcessPid;
end ;
begin
hSnapshot:= CreateToolhelp32Snapshot( $2 , 0 );
if hSnapshot <> INVALID_HANDLE_VALUE then
Result:= ProcessPidByName(hSnapshot, fName);
CloseHandle (hSnapShot);
end ;
|