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. 或者如下代码:unit Unit1; 
 
interface 
 
uses 
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 
  Dialogs, Tlhelp32, StdCtrls, Buttons, CheckLst; 
 
type 
  TForm1 = class(TForm) 
    BitBtn1: TBitBtn; 
    ListBox1: TListBox; 
    Button1: TButton; 
    procedure BitBtn1Click(Sender: TObject); 
    procedure Button1Click(Sender: TObject); 
  private 
    { Private declarations } 
  public 
    { Public declarations } 
  end; 
 
var 
  Form1: TForm1; 
 
procedure Search(Strings:TStrings); 
implementation 
 
{$R *.dfm} 
procedure Search(Strings:TStrings); 
var 
  Snap:THandle; 
  RB:Boolean; 
  PE:TProcessEntry32; 
begin 
  if Strings=nil then 
    Exit; 
  snap:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); 
  if snap = -1 then Exit; 
  try 
    PE.dwSize:=SizeOf(TProcessEntry32); 
    RB:=Process32First(snap,PE); 
    while RB do 
    begin 
      Strings.AddObject(PE.szExeFile,Pointer(PE.th32ProcessID)); 
      PE.dwSize:=SizeOf(TProcessEntry32); 
      RB:=Process32Next(snap,PE); 
    end; 
  finally 
    CloseHandle(snap); 
  end; 
end; 
procedure TForm1.BitBtn1Click(Sender: TObject); 
begin 
  ListBox1.Items.Clear; 
  Search(ListBox1.Items); 
end; 
 
procedure TForm1.Button1Click(Sender: TObject); 
var 
  H:THandle; 
  R:Cardinal; 
begin 
  H:=OpenProcess(PROCESS_TERMINATE,True,LongInt(ListBox1.Items.Objects[ListBox1.ItemIndex])); 
  R:=0; 
  TerminateProcess(H,R); 
  CloseHandle(H); 
end; 
 
end. 
关键的: 
procedure TForm1.Button1Click(Sender: TObject); 
var 
  H:THandle; 
  R:Cardinal; 
begin 
  H:=OpenProcess(PROCESS_TERMINATE,True,LongInt(ListBox1.Items.Objects[ListBox1.ItemIndex])); 
  R:=0; 
  TerminateProcess(H,R); 
  CloseHandle(H); 
end; 
其中ListBox1.Items.Objects[ListBox1.ItemIndex]是在遍历进程时存放的ProcessID