implementation<br> uses TLHelp32;<br>{$R *.dfm}<br><br>procedure TForm1.Button1Click(Sender: TObject);<br>var<br> pe:TProcessEntry32;<br> ph,h:THandle;<br>begin<br> h:=0;<br> listbox1.Items.Clear;<br> ph:=CreateToolHelp32Snapshot(TH32CS_SNAPPROCESS,0);<br> if ph<>0 then<br> pe.dwSize:=sizeof(pe);<br> if process32First(ph,pe) then<br> repeat<br> listbox1.Items.Add(pe.szExeFile);<br> until not Process32Next(ph,pe);<br> closehandle(ph);<br>end;<br><br>procedure TForm1.ListBox1DblClick(Sender: TObject);<br>var<br> ph:Thandle;<br> idid:dword;<br> tmp:string;<br> p:integer;<br> ret:boolean;<br> a: DWORD;<br>begin<br> tmp:=listbox1.Items.Strings[listbox1.ItemIndex];<br> p:=pos('##',tmp)+2;<br> showmessage(inttostr(p));<br> idid:=strtoint(copy(tmp,p,length(tmp)-p));<br> caption:=inttostr(idid);<br> ph:=OpenProcess(PROCESS_TERMINATE,boolean(0),idid);<br> GetExitCodeProcess(ph,a);<br> ret:=TerminateProcess(ph,a);<br> if not ret then showmessage('can not kill it');<br> closehandle(ph);<br>end;<br><br>procedure TForm1.Button2Click(Sender: TObject);<br>begin<br>close;<br>end;<br><br>end.<br>[8D]可能不能调试,自己改。<br>