var H: THandle; P: PDWord; begin H := Findwindow(NIL, Pchar(WindowTitle)); //获取窗体的handle if H <> 0 then begin new(P); GetWindowThreadProcessId(H, P); showmessage('当前结束进程的ID是:'+inttostr(P^)); //获取进程ID if P^ <> 0 then // OpenProcess 获取进程的Handle TerminateProcess结束进程 TerminateProcess(OpenProcess(Process_Terminate, False, P^), 0); end;
H: THandle;
P: PDWord;
begin
H := Findwindow(NIL, Pchar(WindowTitle)); //获取窗体的handle
if H <> 0 then
begin
new(P);
GetWindowThreadProcessId(H, P);
showmessage('当前结束进程的ID是:'+inttostr(P^)); //获取进程ID
if P^ <> 0 then // OpenProcess 获取进程的Handle TerminateProcess结束进程
TerminateProcess(OpenProcess(Process_Terminate, False, P^), 0);
end;