uses tlhelp32;<br>假设要终止的程序的文件名为:project2.exe,那么例程如下:<br>var<br>lppe:tprocessentry32;<br>sshandle:thandle;<br>hh:hwnd;<br>found:boolean;<br>begin<br>sshandle:=createtoolhelp32snapshot(TH32CS_SNAPALL,0);<br>found:=process32first(sshandle,lppe);<br>while found do<br>begin<br> //进行你的处理其中lppe.szExefile就是程序名。<br> if uppercase(extractfilename(lppe.szExeFile))='PROJECT2.EXE' then<br> begin<br> hh:=OpenProcess(PROCESS_ALL_ACCESS,true,lppe.th32ProcessID);<br> TerminateProcess(hh,0);<br> end;<br> found:=process32next(sshandle,lppe);<br>end;<br>end;