File tree Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Expand file tree Collapse file tree 1 file changed +10
-10
lines changed Original file line number Diff line number Diff line change 1
1
#include < windows.h>
2
- #include < tlhelp32.h> // 声明快照头文件
2
+ #include < tlhelp32.h> // 声明快照头文件
3
3
#include < iostream>
4
4
using namespace std ;
5
5
6
6
int main () {
7
7
PROCESSENTRY32 pe32;
8
8
pe32.dwSize = sizeof (pe32);
9
9
10
- HANDLE hprocesssnap = ::CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0 ); // 当前所有进程快照
11
- if (hprocesssnap == INVALID_HANDLE_VALUE) {
12
- cout << " CreateToolhelp32Snapshot失败" << endl;
10
+ HANDLE hpsnap = ::CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0 ); // 当前所有进程快照
11
+ if (hpsnap == INVALID_HANDLE_VALUE) {
12
+ cout << " CreateToolhelp32Snapshot失败" << endl;
13
13
return -1 ;
14
14
}
15
15
16
- BOOL bnext = ::Process32First (hprocesssnap , &pe32); // 遍历当前进程快照
16
+ BOOL bnext = ::Process32First (hpsnap , &pe32); // 遍历当前进程快照
17
17
while (bnext) {
18
- cout << " 进程名称:" << pe32.szExeFile << endl;
19
- cout << " 进程ID号:" << pe32.th32ProcessID << endl << endl;
20
- bnext = ::Process32Next (hprocesssnap , &pe32);
18
+ cout << " 进程名称:" << pe32.szExeFile << endl;
19
+ cout << " 进程ID号:" << pe32.th32ProcessID << endl << endl;
20
+ bnext = ::Process32Next (hpsnap , &pe32);
21
21
}
22
22
23
- ::CloseHandle (hprocesssnap );
23
+ ::CloseHandle (hpsnap );
24
24
25
25
return 0 ;
26
- }
26
+ }
You can’t perform that action at this time.
0 commit comments