获取进程的数量

    技术2022-05-20  56

    #include <assert.h>

    #include <TLHELP32.H>

    int  GetProcessNum(char* ProcessName){ assert(ProcessName);  HANDLE hand = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);;

     //  ASSERT(hand!=NULL);  PROCESSENTRY32 ppp;  if(!Process32First(hand,&ppp))  return 0;   int ProcessNum=0; do  {    if(strnicmp(ppp.szExeFile,ProcessName)==0)  {   ProcessNum++;    }  } while(Process32Next(hand,&ppp)); return ProcessNum; }


    最新回复(0)