实时刷新 进程列表。刷新个十几次后,Process32First返回失败
不知道是什么原因。
- C/C++ code
fGetProcessList(){ m_list.ResetContent(); HANDLE hSnap; CString strPath; LPTSTR path = new TCHAR[MAX_PATH]; hSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); PROCESSENTRY32 process; process.dwSize=sizeof(PROCESSENTRY32); BOOL bResult = Process32First(hSnap,&process); while (bResult) { ZeroMemory(path,MAX_PATH); for (int i=0;i<MAX_PATH;i++) path[i] = process.szExeFile[i]; strPath = path; m_listLog.InsertString(0,strPath ); bResult = Process32Next(hSnap,&process); } delete path; path = NULL; CloseHandle(hSnap);}
------解决方案--------------------
用 GetLastError() 看看得到什么错误?