C语言如何获取当前系统所有进程
来源:优易学  2010-1-20 15:33:50   【优易学:中国教育考试门户网】   资料下载   IT书店

  #include "stdafx.h"

  #include <windows.h>

  #include <tlhelp32.h>

  int main(int argc, char* argv[])

  {

  HANDLE hSnapshot = CreateToolhelp32Snapshot (TH32CS_SNAPPROCESS, 0);

  if (!hSnapshot)

  {

  printf("CreateToolhelp32Snapshot ERROR!\n");

  return 1;

  }

  PROCESSENTRY32 pe32;

  pe32.dwSize = sizeof(PROCESSENTRY32 );

  if (!Process32First (hSnapshot, &pe32))

  {

  printf("Process32First ERROR!\n");

  }

  do

  {

  printf("ProcID:%d---%s\n",pe32.th32ProcessID ,pe32.szExeFile );

  }while(Process32Next (hSnapshot, &pe32));

  return 0;

  }

责任编辑:小草

文章搜索:
 相关文章
热点资讯
资讯快报
热门课程培训