C++ 判断进程是否存在 Bertha 。 2022-06-09 06:59 283阅读 0赞 原文出处:http://blog.csdn.net/zhensoft163/article/details/7967993 #include <windows.h> #include "psapi.h" #include"stdio.h" #include <tlhelp32.h> //判断进程是否存在 //2012-09-10 BOOL FindProcess() { int i=0; PROCESSENTRY32 pe32; pe32.dwSize = sizeof(pe32); HANDLE hProcessSnap = ::CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if(hProcessSnap == INVALID_HANDLE_VALUE) { i+=0; } BOOL bMore = ::Process32First(hProcessSnap, &pe32); while(bMore) { //printf(" 进程名称:%s \n", pe32.szExeFile); if(stricmp("进程名",pe32.szExeFile)==0) { //printf("进程运行中"); i+=1; } bMore = ::Process32Next(hProcessSnap, &pe32); } if(i>1){ //大于1,排除自身 return true; }else{ return false; } }
还没有评论,来说两句吧...