| 关键词: nbsp info HANDLE printf include PROCESSENTRY 32 ListProcess szExeFile ProcessID |
#include "stdafx.h" #include "windows.h" #include "tlhelp32.h" void ListProcess() { HANDLE handle=CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0); PROCESSENTRY32* info=new PROCESSENTRY32; info->dwSize=sizeof(PROCESSENTRY32); int i=0; if(Process32First(handle,info)) { if(GetLastError()==ERROR_NO_MORE_FILES ) { printf("没有进程!"); } else { printf("[PID] \t [进程名称] \n"); //printf("%5d \t %s \n",info->th32ProcessID,info->szExeFile); i++; while(Process32Next(handle,info)!=FALSE) { printf("%5d \t %s \n",info->th32ProcessID,info->szExeFile); i++; } } } CloseHandle(handle); delete info; } int main(int argc, char* argv[]) { ListProcess(); return 0; } |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|