Win32 服务进程和单实例实现

#pragma comment(linker, "/subsystem:\"windows\" /entry:\"mainCRTStartup\"")

HANDLE hMutex = CreateMutexA(NULL, true, "XXX_0D0DDD11-5E3F-4287-BB74-7E3D2C7720EF");
 if (hMutex)
 {
  if (GetLastError() == ERROR_ALREADY_EXISTS)
  {
   //std::cerr << "Program already run...\n"
   //	<< "Press any key to exit..." << std::endl;
   //std::cin.get();
   return 1;
  }
 }
 else
 {
   return 1;
 }

你可能感兴趣的:(Win32 服务进程和单实例实现)