unit u_CheckProcess; 
interface 
 
uses Windows, Classes, PsApi; 
 
function CheckProcess(aProcessName: string): Boolean;//exename(no path,eg hello.exe) 
implementation 
 
function CheckProcess(aProcessName: string): Boolean; 
type 
  integer = DWORD; // different versions of psapi.pas floating around 
var 
  i, pidNeeded: Integer; 
  PIDList: array[0..1000] of Integer; // 1000 should be enough 
  PIDName: array[0..MAX_PATH - 1] of char; 
  PH: THandle; 
begin 
  Result := False; 
  if not Psapi.EnumProcesses(@PIDList, 1000, pidNeeded) then 
  begin 
    Result := False; 
    exit; 
  end; 
  for i := 0 to (pidNeeded div sizeof(Integer) - 1) do 
  begin 
    PH := OpenProcess(PROCESS_QUERY_INFORMATION or PROCESS_VM_READ, False, 
      PIDList[i]); 
    if PH <> 0 then 
    begin 
      if psapi.GetModuleBaseName(PH, 0, PIDName, sizeof(PIDName)) > 0 then 
        if aProcessName = pidName then 
        begin 
          Result := True; 
        end; 
      if PH > 0 then 
        CloseHandle(PH); 
    end; 
  end; 
end; 
end. 取得进程的名称(id),然后killprocess