1、谁能给我讲讲怎么使用互斥量啊
    ReleaseMutex(m_hMutexOneInstance);
2、
   HANDLE m_hMutexOneInstance;  声明一个互斥量,之后为什么还要
   
    1〉CloseHandle(m_hMutexOneInstance);
2〉m_hMutexOneInstance = NULL;
   我查了一下CloseHandle()用于closes an open object handle,
难道这个互斥量是一个对象吗?

解决方案 »

  1.   

    1 .HANDLE m_hMutexOneInstance; //声明一个互斥量的句柄
    2. hMutexOneInstance = ::CreateMutex( NULL, false, 0 );//参数参阅MSDN
    3. 等待互斥
           DWORD dwWaitResult=WaitForSingleObject( hMutexOneInstance , 5000L );
            switch (dwWaitResult) 
    {
    case WAIT_OBJECT_0: 
    m_locked = true;
                    //MessageBox(NULL,"已经锁定","锁定",MB_OK | 0x00200000L);
    break;  case WAIT_TIMEOUT: 
    );
    return FALSE;  case WAIT_ABANDONED: 
    return FALSE; 
    }4。释放互斥  ReleaseMutex(m_hMutex);
    5. 释放资源
       ColseHandle(hMutexOneInstance );
       
      

  2.   

    CloseHandle(hMutexOneInstance );
    就够了对不?不用hMutexOneInstance=NULL;