用互斥锁实现程序只能有一个实例

HANDLE mSingleInstanceMutex = NULL;

bool moreThanOneInstance()
{
    mSingleInstanceMutex = CreateMutex(NULL, FALSE, L"SingleNFDLinkGUI");
    if (NULL == mSingleInstanceMutex || ERROR_ALREADY_EXISTS == GetLastError())
    {
        return true;
    }
    else
    {
        return false;
    }
}

 

posted on 2019-02-28 15:54  liujx2019  阅读(334)  评论(0编辑  收藏  举报

导航