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;<br>********************<br>HANDLE hProcess<br>Windows NT/2000: The handle must have PROCESS_TERMINATE access. <br>For more information, see Process Security and Access Rights. <br><br>所以要先使用 <br>DWORD SetSecurityInfo(<br> HANDLE handle, // handle to object<br> SE_OBJECT_TYPE ObjectType, // object type<br> SECURITY_INFORMATION SecurityInfo, // buffer<br> PSID psidOwner, // new owner SID<br> PSID psidGroup, // new primary group SID<br> PACL pDacl, // new DACL<br> PACL pSacl // new SACL<br>);<br><br>