//设置只能运行一个实例 //"LYCHPCSMMutex" 这个名字可以随意起 CSMStationMutex = ::CreateMutex(NULL,TRUE,"LYCHPCSMMutex"); if(GetLastError() == ERROR_ALREADY_EXISTS) { CWnd *pPrevWnd = CWnd::GetDesktopWindow()->GetWindow(GW_CHILD); while(pPrevWnd) { if(::GetProp(pPrevWnd->GetSafeHwnd(),"LYCHPCSMMutex")) { if(pPrevWnd->IsIconic()) pPrevWnd->ShowWindow(SW_RESTORE); pPrevWnd->SetForegroundWindow(); pPrevWnd->GetLastActivePopup()->SetForegroundWindow(); return FALSE; } pPrevWnd = pPrevWnd->GetWindow(GW_HWNDNEXT); } ::CloseHandle(CSMStationMutex); return FALSE; } if(CSMStationMutex == NULL) return FALSE;