pe32 . dwsize = sizeof(pe32);//在使用此結構之前設置其大小。
HANDLE hprocess snapshot =::createtoolhelp 32 snapshot(th 32 cs _ snap process,0);
CString s;
if(無效句柄值== hProcessSnapshot)
{
S = _T("獲取系統進程失敗!");
AfxMessageBox
返回;
}
//遍歷進程快照,依次顯示每個進程的信息。
int I = 0;
BOOL b more =::process 32 first(hProcessSnapshot,& amppe32);
while(b更多)
{
CString str =(pe32 . SZ exefile);
if (str == _T("notepad.exe "))
{
i++;
}
b more =::process 32 next(hProcessSnapshot,& amppe32);
}
南Format(_T("當前打開的記事本程序數量為:%d "),I);
AfxMessageBox
* close handle(hProcessSnapshot);