BOOL CTorrentWizardApp::InitInstance() { CCommandLineInfoEx cmdInfo; ParseCommandLine(cmdInfo); cmdInfo.GetOption( _T("sourcefile"), m_sCommandLineSourceFile ); cmdInfo.GetOption( _T("destination"), m_sCommandLineDestination ); cmdInfo.GetOption( _T("tracker"), m_sCommandLineTracker ); cmdInfo.GetOption( _T("comment"), m_sCommandLineComment ); if ( m_sCommandLineSourceFile.GetLength() > 0 && m_sCommandLineDestination.GetLength() > 0 && m_sCommandLineTracker.GetLength() > 0 ) { if ( m_sCommandLineComment.IsEmpty() ) m_sCommandLineComment = _T("http://shareaza.sourceforge.net/"); } SetRegistryKey( _T("Shareaza") ); InitEnvironment(); InitResources(); CWizardSheet pSheet; CWelcomePage pWelcome; CSinglePage pSingle; CPackagePage pPackage; CTrackerPage pTracker; CCommentPage pComment; COutputPage pOutput; CFinishedPage pFinished; m_pSheet = &pSheet; pSheet.AddPage( &pWelcome ); pSheet.AddPage( &pSingle ); pSheet.AddPage( &pPackage ); pSheet.AddPage( &pTracker ); pSheet.AddPage( &pOutput ); pSheet.AddPage( &pComment ); pSheet.AddPage( &pFinished ); pSheet.DoModal(); return FALSE; }
BOOL CTorrentEnvyApp::InitInstance() { CCommandLineInfoEx cmdInfo; ParseCommandLine( cmdInfo ); cmdInfo.GetOption( L"sourcefile", m_sCommandLineSourceFile ); cmdInfo.GetOption( L"destination", m_sCommandLineDestination ); cmdInfo.GetOption( L"tracker", m_sCommandLineTracker ); cmdInfo.GetOption( L"comment", m_sCommandLineComment ); if ( ! m_sCommandLineSourceFile.IsEmpty() && ! m_sCommandLineDestination.IsEmpty() && ! m_sCommandLineTracker.IsEmpty() ) { if ( m_sCommandLineComment.IsEmpty() ) m_sCommandLineComment = L"http://getenvy.com/"; } else { // Test prior app instance for non-commandline HANDLE pMutex = CreateMutex( NULL, FALSE, L"Global\\TorrentEnvy" ); if ( GetLastError() == ERROR_ALREADY_EXISTS ) { // Show first instance //if ( CWnd* pWnd = CWnd::FindWindow( L"TorrentEnvy", NULL ) ) //{ // pWnd->SendMessage( WM_SYSCOMMAND, SC_RESTORE ); // pWnd->ShowWindow( SW_SHOWNORMAL ); // pWnd->BringWindowToTop(); // pWnd->SetForegroundWindow(); //} if ( MessageBox( NULL, (LPCWSTR)L"TorrentEnvy is currently running.\nDo you wish to open a new window?", (LPCWSTR)L"Envy TorrentEnvy", MB_ICONQUESTION | MB_OKCANCEL | MB_SETFOREGROUND ) == IDCANCEL ) { CloseHandle( pMutex ); return FALSE; } } // else Continue... } SetRegistryKey( L"Envy" ); InitEnvironment(); InitResources(); CWizardSheet pSheet; CWelcomePage pWelcome; CExpertPage pExpert; CSinglePage pSingle; CPackagePage pPackage; CTrackerPage pTracker; CCommentPage pComment; COutputPage pOutput; CFinishedPage pFinished; m_pSheet = &pSheet; pSheet.AddPage( &pWelcome ); pSheet.AddPage( &pExpert ); pSheet.AddPage( &pSingle ); pSheet.AddPage( &pPackage ); pSheet.AddPage( &pTracker ); pSheet.AddPage( &pComment ); pSheet.AddPage( &pOutput ); pSheet.AddPage( &pFinished ); if ( cmdInfo.m_sPaths.GetCount() ) { if ( m_sCommandLineSourceFile.IsEmpty() && cmdInfo.m_sPaths.GetCount() == 1 ) m_sCommandLineSourceFile = cmdInfo.m_sPaths.GetHead(); for ( int i = (int)cmdInfo.m_sPaths.GetCount(); i; i-- ) m_sCommandLinePaths.AddTail( cmdInfo.m_sPaths.RemoveHead() ); } pSheet.DoModal(); return FALSE; }