第二例:查看进程程序

Posted 泛未分晨

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了第二例:查看进程程序相关的知识,希望对你有一定的参考价值。

如第一例,不赘言。

代码如下:

 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 }

 

以上是关于第二例:查看进程程序的主要内容,如果未能解决你的问题,请参考以下文章