#include<windows.h>
#include<stdio.h>
int main(int argc,char *argv[])
{
HANDLE hMutex;
DWORD dwErr;
hMutex=CreateMutex(NULL,//无安全描述
FALSE,//没有所有者
       "HACK");//对象名
 if(hMutex==NULL)//hMutex为NULL标示创建失败
{
MessageBox(NULL,"CreateMutex error!",NULL,MB_OK);
}
else
{
dwErr=GetLastError();
if(dwErr==ERROR_ALREADY_EXISTS)//互斥对象已经存在
{
MessageBox(NULL,"Application has already running",NULL,MB_OK);
ExitProcess(0);
}

}
getchar();
return 0;
}

相关文章:

  • 2021-12-19
  • 2022-01-24
  • 2021-11-24
  • 2022-02-11
  • 2021-06-08
  • 2021-02-22
  • 2022-12-23
猜你喜欢
  • 2021-10-01
  • 2021-09-18
  • 2021-10-28
  • 2021-09-21
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案