#include <tlhelp32.h>
void CProginfoDlg::OnButton1()
{
//其中m_lstProg为CListBox。
// TODO: Add your control notification handler code here
HANDLE hsnapshot=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
PROCESSENTRY32 pe;
CString ProcessName;
CString ProcessID;
CString BasePriority;
CString str;
int retval=Process32First(hsnapshot,&pe);
int CurItemIndex=0;
m_lstProg.ResetContent();
do
{
ProcessName=pe.szExeFile;
ProcessID.Format( "%d ",pe.th32ProcessID);
BasePriority.Format( "%d ",pe.pcPriClassBase);
str = ProcessName + ProcessID + BasePriority;
str.Format(_T(str)); //这里 格式 一点 要注意
m_lstProg.AddString(str);
}
while(Process32Next(hsnapshot,&pe));
CloseHandle(hsnapshot);
}