BOOL CIHISSERVERApp::InitInstance()
{
....
/*--------------------------------------*/
CString mutexname = "oncemutex ";
myMutex = ::OpenMutex(MUTEX_ALL_ACCESS,FALSE,mutexname);
if(myMutex == NULL )
{
myMutex = ::CreateMutex(NULL,TRUE,mutexname);
}
else
{
HWND mainHandle = ::FindWindow(NULL, "IHIS安防报警服务器 ");
if ( !mainHandle )
{
AfxMessageBox( "没有发现窗口 ");
}
SetForegroundWindow( mainHandle );
ShowWindow(mainHandle,SW_SHOWMAXIMIZED);
// 当第一个程序最小话到任务栏时,消除任务栏的图彪
NOTIFYICONDATA nid;
nid.cbSize = sizeof( NOTIFYICONDATA );
nid.hWnd = mainHandle;
nid.uID = IDR_MAINFRAME;
nid.uFlags = 0;
Shell_NotifyIcon(NIM_DELETE,&nid);
return false;
}
/*--------------------------------------*/
}