//首先在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;
}