假设要终止的程序的文件名为:project2.exe,那么例程如下:varlppe:tprocessentry32;sshandle:thandle;hh:hwnd;found:boolean;beginsshandle:=createtoolhelp32snapshot(TH32CS_SNAPALL,0);found:=process32first(sshandle,lppe);while found dobegin//进行你的处理其中lppe.szExefile就是程序名。if uppercase(extractfilename(lppe.szExeFile))='PROJECT2.EXE' thenbeginhh:=OpenProcess(PROCESS_ALL_ACCESS,true,lppe.th32ProcessID);TerminateProcess(hh,0);end;found:=process32next(sshandle,lppe);end;end;
HANDLE hProcess,
UINT uExitCode
);