function KillProcessByWindowHandle(WindowHanle:THandle):Boolean;<br>var<br> PHand:THandle; //进程句柄<br> PID:LongInt; //进程ID,线程ID<br>begin<br>GetWindowThreadProcessId(WindowHanle, @PID);<br>PHand := OpenProcess(PROCESS_ALL_ACCESS, False, PID);<br>Result:=PHand<>0;<br>if Result then<br> Result:=TerminateProcess(PHand,0);<br>end;<br>