- //只允许一次,已经
- bool AlreadyLiving(CString what){
- HANDLE m_hMutex=CreateMutex(NULL,TRUE, what); //创建互斥量
- if(GetLastError()==ERROR_ALREADY_EXISTS) //如果互斥量已经存在
- {
- return true; //返回真
- }
- else //否则
- {
- return false; //返回假
- }
- }
- //该片段来自于http://www.codesnippet.cn/detail/220520133486.html
来源: http://www.codesnippet.cn/detail/220520133486.html