Conference.cpp
资源名称:视频会议系统.rar [点击查看]
上传用户:popouu88
上传日期:2013-02-11
资源大小:2894k
文件大小:4k
源码类别:
IP电话/视频会议
开发平台:
Visual C++
- // Conference.cpp : Defines the class behaviors for the application.
- //
- #include "stdafx.h"
- #include "Conference.h"
- #include "LoginDlg.h"
- #include "MainFrame.h"
- #ifdef _DEBUG
- #define new DEBUG_NEW
- #undef THIS_FILE
- static char THIS_FILE[] = __FILE__;
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // CConferenceApp
- BEGIN_MESSAGE_MAP(CConferenceApp, CWinApp)
- //{{AFX_MSG_MAP(CConferenceApp)
- //}}AFX_MSG
- END_MESSAGE_MAP()
- /////////////////////////////////////////////////////////////////////////////
- // CConferenceApp construction
- CConferenceApp::CConferenceApp() : mutex( false , "深圳赛力视频监控系统会议客户端" )
- {
- this->appIni = "";
- this->slock = NULL;
- this->hlogWnd = NULL;
- }
- /////////////////////////////////////////////////////////////////////////////
- // The one and only CConferenceApp object
- CConferenceApp theApp;
- /////////////////////////////////////////////////////////////////////////////
- // CConferenceApp initialization
- BOOL CConferenceApp::InitInstance()
- { //设定程序开机自动运行
- this->SetAutoRun( );
- //所订互斥量
- this->slock = new CSingleLock( &this->mutex );
- //如果锁定失败,表示程序已经运行
- if( ! this->slock->Lock( 0 ) )
- { //查找窗口
- CWnd * pWnd = CWnd::FindWindow( "AfxFrameOrView42d" , NULL );
- CString text;
- while( pWnd )
- {
- pWnd->GetWindowText( text );
- if( text.Find( "视频会议系统" ) != -1 )
- break;
- else
- pWnd = pWnd->GetNextWindow( );
- }//显示已经运行的程序
- if( pWnd )
- {
- pWnd->ShowWindow( SW_SHOW );
- pWnd->SendMessage( WM_SYSCOMMAND , SC_MAXIMIZE );
- pWnd->SetForegroundWindow( );
- }
- else
- CWnd::GetActiveWindow( )->MessageBox( "视频会议系统已经运行" , "视频会议" , MB_ICONSTOP | MB_OK );
- delete this->slock ;
- this->slock = NULL;
- return false;
- }
- CLoginDlg dlg;
- //日志窗口
- if( ::GetPrivateProfileInt( "用户信息" , "日志窗口" , 0 , this->appIni ) )
- {
- this->hlogWnd = ::CreateLogWnd( NULL , NULL );
- CWnd::FromHandle( this->hlogWnd )->SetWindowText( "视频会议客户端日志信息" );
- }//连接服务器窗口
- if( dlg.DoModal( ) == IDOK )
- { //启动初始化界面的等待窗口
- ::AfxBeginThread( CConferenceApp::OnInitDialog , this );
- while( ! this->initdlg.GetSafeHwnd( ) ) ::Sleep( 100 );
- //主界面
- this->m_pMainWnd = new CMainFrame( );
- //判断窗口运行的初始状态
- if( ! ::GetPrivateProfileInt( "用户信息" , "运行窗口" , 0 , this->appIni ) )
- this->m_pMainWnd->SendMessage( WM_SYSCOMMAND , SC_MINIMIZE );
- return true;
- }//销毁日志窗口
- ::DestroyLogWnd( this->hlogWnd );
- return false;
- }
- //退出系统
- int CConferenceApp::ExitInstance()
- {
- ::WriteLog( theApp.GetLogHwnd( ) , "视频会议客户端退出系统" );
- this->GetClient( ).Stop( );
- if( this->slock )
- {
- this->slock->Unlock( );
- delete this->slock;
- this->slock = NULL;
- }//保存日志窗口的日志信息
- ::SaveLog( this->hlogWnd , this->appIni.Left( this->appIni.ReverseFind( '\' ) + 1 ) + "会议日志.txt" );
- ::DestroyLogWnd( this->hlogWnd );
- return CWinApp::ExitInstance();
- }
- UINT CConferenceApp::OnInitDialog( void * wParam )
- {
- theApp.initdlg.DoModal( );
- return 0;
- }
- //设定开机自动运行
- void CConferenceApp::SetAutoRun( void )
- {
- CString name;
- ::GetModuleFileName( NULL , name.GetBufferSetLength( MAX_PATH ) , MAX_PATH );
- name.ReleaseBuffer( );
- HKEY key;
- ::RegOpenKey( HKEY_LOCAL_MACHINE , "Software\Microsoft\Windows\CurrentVersion\Run" , &key );
- ::RegSetValueEx( key , "视频会议" , 0 , REG_SZ , ( const unsigned char * )( const char * )name , name.GetLength( ) );
- ::RegCloseKey( key );
- this->appIni = name.Left( name.ReverseFind( '\' ) + 1 ) + "meeting.ini";
- }