1 BOOL CDriverToolsDlg::ZyShowWindowsProInfo(void)
2 {
3 CString str;
4 CString Path;
5 PROCESSENTRY32 pe32;
6
7 //在使用这个结构前,先设置它的大小
8
9 pe32.dwSize = sizeof(pe32);
10
11 //给系统内所有的进程拍个快照
12
13 HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
14 if (hProcessSnap == INVALID_HANDLE_VALUE)
15 {
16 ::MessageBox(NULL,"CreateToolhelp32Snapshot 调用失败[Error]","警告",MB_OK);
17 return -1;
18 }
19
20 int i = 0;
21 BOOL bMore = ::Process32First(hProcessSnap,&pe32);
22 while (bMore)
23 {
24 m_listProcessInfo.InsertItem(i,pe32.szExeFile);
25 str.Format("%d",pe32.th32ProcessID);
26 m_listProcessInfo.SetItemText(i,1,str);
27
28 ::GetProcessFilePath(::OpenProcess(PROCESS_ALL_ACCESS,FALSE,pe32.th32ProcessID),Path);
29 m_listProcessInfo.SetItemText(i,2,Path);
30 bMore = ::Process32Next(hProcessSnap,&pe32);
31 i++;
32 }
33 str.Format("%d",i);
34 ::SetWindowText(m_processnumber.m_hWnd,str);
35 ::CloseHandle(hProcessSnap);
36 return TRUE;
37 }