检查一个exe是不是在运行

  1. #include "Tlhelp32.h"
  2. bool CheckRunning( char* exe )
  3. {
  4.     HANDLE handle = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
  5.     if (handle == NULL) false;
  6.     PROCESSENTRY32 processinfo;
  7.     processinfo.dwSize = sizeof(processinfo);
  8.     bool status = Process32First(handle, &processinfo);
  9.     while (status == true)
  10.     {
  11.         if( _stricmp(exe, processinfo.szExeFile) == 0 ) 
  12.         {
  13.             CloseHandle(handle);
  14.             return true;
  15.         }
  16.         status = Process32Next(handle, &processinfo);
  17.     }
  18.     CloseHandle(handle);
  19.     return false;
  20. }

猜你喜欢

转载自blog.csdn.net/KAMILLE/article/details/2973756
今日推荐