CreateMutex实现只能打开一个客户端

#include "stdafx.h"
#include <Windows.h>
#include <iostream>

using namespace std;

int _tmain (int argc, LPTSTR argv[])
{
    HANDLE h=CreateMutex(NULL,TRUE,"AAAAAAA");
    if(GetLastError()==ERROR_ALREADY_EXISTS){
        CloseHandle(h);
        return 0;  
    }   
    system("pause");
    CloseHandle(h);
    return 0;
}

 

posted on 2014-05-30 14:30  上海—Michael  阅读(312)  评论(0编辑  收藏  举报