#include <windows.h> #include <tlhelp32.h> int FindProcess(char *s) //返回此进程运行个数 { int cnt=0; PROCESSENTRY32 pe32; pe32.dwSize = sizeof(pe32); HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); bool bMore = ::Process32First(hProcessSnap, &pe32); while(bMore) { //printf("%s\n",pe32.szExeFile); if(strcmp(s,pe32.szExeFile)==0) cnt++; bMore = ::Process32Next(hProcessSnap, &pe32); } return cnt; }
时间: 2024-12-15 07:14:04