第二例:查看进程程序

如第一例,不赘言。

代码如下:

 1 #include<windows.h>
 2 #include<stdio.h>
 3 #include<tlhelp32.h>
 4 
 5 int main(int argc,char* argv[])
 6 {
 7     PROCESSENTRY32 pe32;
 8     pe32.dwSize = sizeof(pe32);
 9     HANDLE hProcesshandle = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
10     if(hProcesshandle != INVALID_HANDLE_VALUE)
11     {
12         bool bMore = ::Process32First(hProcesshandle,&pe32);
13         while(bMore)
14         {
15             printf("ThreadUsage:%d\n",pe32.cntUsage);
16             printf("ProcessId:%d\n",pe32.th32ProcessID);
17             printf("ProcessName:%s\n\n",pe32.szExeFile);
18             
19             bMore = ::Process32Next(hProcesshandle,&pe32);
20         }
21     }
22     
23     ::CloseHandle(hProcesshandle);
24     
25     system("pause");
26     return 0;
27 }

 

posted @ 2017-01-30 00:04  泛未分晨  阅读(215)  评论(0编辑  收藏  举报