如何用vc编写程序获取系统进程

来源:百度知道 编辑:UC知道 时间:2024/05/24 09:34:46
我想使用vc编写程序,获取系统进程。并且想每隔一秒钟就获得一次。给出大体提示给20分,给出详细代码加30分,绝不食言。

void CApp1Dlg::ListProcess()
{
CString sItem;
PROCESSENTRY32 pe;
pe.dwSize=sizeof(pe);
while(m_prcls.GetCount()>0){
m_prcls.DeleteString(0);
}
HANDLE hSnapshot= CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
Process32First(hSnapshot,&pe);
do{
sItem.Format("%s[PID:%d]",pe.szExeFile,pe.th32ProcessID);
int Index=m_prcls.InsertString(m_prcls.GetCount(),sItem);
m_prcls.SetItemData(Index,pe.th32ProcessID);
}while (Process32Next(hSnapshot,&pe));
CloseHandle(hSnapshot);
}