uses tlhelp32;procedure TForm1.Button1Click(Sender: TObject);
var lppe:Tprocessentry32;
    hh:Thandle;
begin
     hh:=createtoolhelp32snapshot(TH32CS_SNAPALL,0);
     if process32first(hh,lppe) then
       repeat
          listbox1.items.add(format('<%x>%s',[lppe.th32ProcessID,extractfilename(lppe.szExeFile)]));
       until not process32next(hh,lppe);
     CloseHandle(hh);
end;

解决方案 »

  1.   

    请问:createtoolhelp32snapshot(th32cs_snapall,0)这个函数返回的是什么数据呢?能解释一下它的参数都是做什么的吗?我看的不是很清楚。
      

  2.   

    th32cs_snapall 表示所有TH32CS_SNAPHEAPLIST, TH32CS_SNAPMODULE, TH32CS_SNAPPROCESS, and TH32CS_SNAPTHREAD类型的快照
    if return<0 then
      fail
    else
      succ