FSnapshotHandle:=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
//由 CreateToolhelp32Snapshot 返回系统快照句柄;
//指向 ProcessEntry32 结构
FProcessENtry32.dwSize:=sizeof(FProcessENtry32);
//获取该结构体大小
ContinueLoop:=Process32First(FSnapshotHandle,FProcessEntry32);
//获得第一个进程的信息
while integer(ContinueLoop)<>0 do //获取进程信息成功
begin
NewItem:=ListView1.Items.Add;
if ProHan.Checked then
NewItem.Caption:=FProcessENtry32.szExeFile;
if ProId.Checked then
NewItem.SubItems.Add(IntToStr(FProcessEntry32.th32ProcessID));
if ProParID.Checked then
NewItem.SubItems.Add(IntToStr(FProcessEntry32.th32ParentProcessID));
If ProThrNmu.Checked then
NewItem.SubItems.Add(IntToStr(FProcessEntry32.cntThreads));
if ProPriClaBas.Checked then
NewItem.SubItems.Add(IntToStr(FProcessEntry32.pcPriClassBase));
//将信息加入列表
ContinueLoop:=process32Next(FSnapshotHandle,FProcessEntry32);
//查找下一个进程
end;
CloseHandle(FSnapshotHandle);
//关闭快照列表