天狼鼠

  博客园 :: 首页 :: 博问 :: 闪存 :: 新随笔 :: 联系 :: 订阅 订阅 :: 管理 ::
//首先在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;
 }

posted on 2011-03-20 16:25  情有独钟  阅读(197)  评论(0编辑  收藏  举报