• 让程序只运行一个实例的方法


    //首先在InitInstance()函数中创建一个同步对象,如果(GetLastError()返回ERROR_ALREADY_EXISTS就表明存在
      //一个应用实例了,返回false取消
      // 创建同步对象


    //By cryfish
     hMutexOneInstantance=CreateMutex(NULL,TRUE,_T("PreventSecondInstance"));
     if(GetLastError()==ERROR_ALREADY_EXISTS)
      bFound=TRUE;
     if(hMutexOneInstantance)
      ReleaseMutex(hMutexOneInstantance);
     if (bFound==TRUE)
     { ::AfxMessageBox("You have Run one");
     return false;
     }

    //首先在InitInstance()函数中创建一个同步对象,如果(GetLastError()返回ERROR_ALREADY_EXISTS就表明存在
      //一个应用实例了,返回false取消
      // 创建同步对象


    //By cryfish
     hMutexOneInstantance=CreateMutex(NULL,TRUE,_T("PreventSecondInstance"));
     if(GetLastError()==ERROR_ALREADY_EXISTS)
      bFound=TRUE;
     if(hMutexOneInstantance)
      ReleaseMutex(hMutexOneInstantance);
     if (bFound==TRUE)
     { ::AfxMessageBox("You have Run one");
     return false;
     }

  • 相关阅读:
    JVM
    关于filter
    session
    xml
    互联网应用和企业级项目的区别
    本学期javaee目标
    团队项目软件度量
    团队项目总结
    团队项目来换网最新
    ubuntu18.04 编译opencv4.4.0 带cuda加速,ffmpeg
  • 原文地址:https://www.cnblogs.com/tianlangshu/p/1989509.html
Copyright © 2020-2023  润新知