window调用api列出当前所有进程示例
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <tlhelp32.h>
void PrintProcessList();
int main(){
PrintProcessList();
system("pause");
return 0;
}
void PrintProcessList(){
HANDLE pHandle;
PROCESSENTRY32 proc;
DWORD procId;
pHandle = CreateToolhelp32Snapshot(0x2,0x0);
if(pHandle==INVALID_HANDLE_VALUE){
return;
}
proc.dwSize = sizeof(PROCESSENTRY32);
while(Process32Next(pHandle,&proc)){
printf("ProcessName : %s - ProcessID : %d\r\n",proc.szExeFile,proc.th32ProcessID);
}
CloseHandle(pHandle);
return;
}
上一篇:基于WTL 双缓冲(double buffer)绘图的分析详解
栏 目:C代码
下一篇:VC++文件监控之ReadDirectoryChangesW
本文地址:http://www.codeinn.net/misctech/101370.html