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

HANDLE mSingleInstanceMutex = NULL;

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

猜你喜欢

转载自www.cnblogs.com/liujx2019/p/10450932.html
今日推荐