http://bbs.youkuaiyun.com/topics/360256656
类似于这个:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
|
#include <Windows.h>
#include <TlHelp32.h>
#include <stdio.h>
#include <tchar.h>
#include <locale.h>
BOOL
GetProcess()
{
HANDLE
hProcess = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
//建立进程快照
if
(INVALID_HANDLE_VALUE == hProcess)
{
printf
(
"获取进程信息失败!!!\n"
);
return
FALSE;
}
//成功获取进程信息
PROCESSENTRY32 pe32;
pe32.dwSize =
sizeof
(PROCESSENTRY32);
BOOL
moreProc = Process32First(hProcess, &pe32);
while
(moreProc)
//枚举所有进程
{
_tprintf(_T(
"进程名称:%s\n"
), pe32.szExeFile);
moreProc = Process32Next(hProcess, &pe32);
}
CloseHandle(hProcess);
//释放进程快照
return
TRUE;
}
int
main(
int
argc,
char
* argv[])
{
setlocale
(LC_ALL,
""
);
GetProcess();
return
0;
}
|