我晕!这段代码错在哪里?(关于进程列表)
为什么有时有结果有时没有结果?
界面上只有一个ListBox和一个Button。
use TLHelp32
procedure TForm1.Button1Click(Sender: TObject);
var
lppe: TProcessEntry32;
found : boolean;
Hand : THandle;
begin
Hand := CreateToolhelp32Snapshot(TH32CS_SNAPALL,0);
found := Process32First(Hand,lppe);
while found do
begin
ListBox1.Items.Add(StrPas(lppe.szExeFile));//列出所有进程。
found := Process32Next(Hand,lppe);
end;
end;