int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); hInst = hInstance; if (!CheckSingleInstance()) return 1; HANDLE hSplashBitmap = static_cast<HBITMAP>(LoadImage(hInst, MAKEINTRESOURCE(IDB_SPLASH), IMAGE_BITMAP, 0, 0, 0)); if (hSplashBitmap) { CreateThread(NULL, 0, SplashScreenThread, hSplashBitmap, 0, NULL); } if (!LocateJVM()) return 1; if (!LoadVMOptions()) return 1; if (!LoadJVMLibrary()) return 1; if (!CreateJVM()) return 1; if (!RunMainClass()) return 1; jvm->DestroyJavaVM(); terminating = true; SetEvent(hEvent); WaitForSingleObject(hSingleInstanceWatcherThread, INFINITE); CloseHandle(hEvent); CloseHandle(hFileMapping); return 0; }
int APIENTRY _tWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPTSTR lpCmdLine, int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); hInst = hInstance; if (__argc == 2 && _wcsicmp(__wargv[0], _T("SPLASH")) == 0) { HBITMAP hSplashBitmap = static_cast<HBITMAP>(LoadImage(hInst, MAKEINTRESOURCE(IDB_SPLASH), IMAGE_BITMAP, 0, 0, 0)); if (hSplashBitmap) { parentProcId = _wtoi(__wargv[1]); parentProcHandle = OpenProcess(SYNCHRONIZE, FALSE, parentProcId); if (IsParentProcessRunning(parentProcHandle)) SplashScreen(hSplashBitmap); } CloseHandle(parentProcHandle); return 0; } //it's OK to return 0 here, because the control is transferred to the first instance if (!CheckSingleInstance()) return 0; if (nativesplash = wcsstr(lpCmdLine, _T("/nativesplash")) != NULL) StartSplashProcess(); if (!LocateJVM()) return 1; if (!LoadVMOptions()) return 1; if (!LoadJVMLibrary()) return 1; if (!CreateJVM()) return 1; hSingleInstanceWatcherThread = CreateThread(NULL, 0, SingleInstanceThread, NULL, 0, NULL); if (!RunMainClass()) return 1; jvm->DestroyJavaVM(); terminating = true; SetEvent(hEvent); WaitForSingleObject(hSingleInstanceWatcherThread, INFINITE); CloseHandle(hEvent); CloseHandle(hFileMapping); return 0; }
BOOL CMainApp::InitInstance() { if(!CheckSingleInstance()) { return FALSE; } // 如果一个运行在 Windows XP 上的应用程序清单指定要 // 使用 ComCtl32.dll 版本 6 或更高版本来启用可视化方式, //则需要 InitCommonControlsEx()。否则,将无法创建窗口。 INITCOMMONCONTROLSEX InitCtrls; InitCtrls.dwSize = sizeof(InitCtrls); // 将它设置为包括所有要在应用程序中使用的 // 公共控件类。 InitCtrls.dwICC = ICC_WIN95_CLASSES; InitCommonControlsEx(&InitCtrls); CWinApp::InitInstance(); AfxEnableControlContainer(); // 标准初始化 // 如果未使用这些功能并希望减小 // 最终可执行文件的大小,则应移除下列 // 不需要的特定初始化例程 // 更改用于存储设置的注册表项 // TODO: 应适当修改该字符串, // 例如修改为公司或组织名 SetRegistryKey(_T("应用程序向导生成的本地应用程序")); //虚函数调用捕获 _set_purecall_handler(PurecallHandler); module_manager.PushEvent(MakeEvent<MODULE_ID_CORE>()(Hall::EVENT_VALUE_HALL_CREATEANDSHOW,MODULE_ID_HALL)); //module_manager.PushEvent(MakeEvent<MODULE_ID_ROOM>()(Room::EVENT_VALUE_TEST,MODULE_ID_ROOM)); //模块管理单元启动 module_manager.Construct(); module_manager.run(); module_manager.Destruct(); return FALSE; }
BOOL CBetaPatchClientApp::InitInstance() { AfxEnableControlContainer(); #ifdef _AFXDLL Enable3dControls(); // Call this when using MFC in a shared DLL #else Enable3dControlsStatic(); // Call this when linking to MFC statically #endif BOOL bSkipPatch = FALSE; CHECK_TYPE type = CheckSingleInstance(); switch( type ) { case CHECK_FALSE: return FALSE; case CHECK_SKIP: RunClient(); return FALSE; } ::DeleteFile( PATCH_LOGFILE ); ::DeleteFile( "NewFlyff.exe" ); if( InitPath() == FALSE ) // 레지스트리에서 실행 Path를 얻어 지정한다. return FALSE; if( CheckDirectXVersion() == FALSE ) { AfxMessageBox( IDS_DIRECTX_INSTALL ); // DirectX 9가 설치되어 있지 않습니다. return FALSE; } CBetaPatchClientDlg dlg; m_pMainWnd = &dlg; g_pDlg = &dlg; dlg.DoModal(); return FALSE; }
BOOL CFamiTrackerApp::InitInstance() { // InitCommonControls() is required on Windows XP if an application // manifest specifies use of ComCtl32.dll version 6 or later to enable // visual styles. Otherwise, any window creation will fail. InitCommonControls(); #ifdef SUPPORT_TRANSLATIONS LoadLocalization(); #endif CWinApp::InitInstance(); TRACE("App: InitInstance\n"); if (!AfxOleInit()) { TRACE("OLE initialization failed\n"); } // Standard initialization // If you are not using these features and wish to reduce the size // of your final executable, you should remove from the following // the specific initialization routines you do not need // Change the registry key under which our settings are stored // TODO: You should modify this string to be something appropriate // such as the name of your company or organization SetRegistryKey(_T("")); LoadStdProfileSettings(MAX_RECENT_FILES); // Load standard INI file options (including MRU) // Load program settings m_pSettings = CSettings::GetObject(); m_pSettings->LoadSettings(); // Parse command line for standard shell commands, DDE, file open + some custom ones CFTCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); if (CheckSingleInstance(cmdInfo)) return FALSE; //who: added by Derek Andrews <*****@*****.**> //why: Load all custom exporter plugins on startup. TCHAR pathToPlugins[MAX_PATH]; GetModuleFileName(NULL, pathToPlugins, MAX_PATH); PathRemoveFileSpec(pathToPlugins); PathAppend(pathToPlugins, _T("\\Plugins")); m_customExporters = new CCustomExporters( pathToPlugins ); // Load custom accelerator m_pAccel = new CAccelerator(); m_pAccel->LoadShortcuts(m_pSettings); m_pAccel->Setup(); // Create the MIDI interface m_pMIDI = new CMIDI(); // Create sound generator m_pSoundGenerator = new CSoundGen(); // Create channel map m_pChannelMap = new CChannelMap(); // Start sound generator thread, initially suspended if (!m_pSoundGenerator->CreateThread(CREATE_SUSPENDED)) { // If failed, restore and save default settings m_pSettings->DefaultSettings(); m_pSettings->SaveSettings(); // Show message and quit AfxMessageBox(IDS_START_ERROR, MB_ICONERROR); return FALSE; } // Check if the application is themed CheckAppThemed(); // Register the application's document templates. Document templates // serve as the connection between documents, frame windows and views CDocTemplate0CC* pDocTemplate = new CDocTemplate0CC( // // // IDR_MAINFRAME, RUNTIME_CLASS(CFamiTrackerDoc), RUNTIME_CLASS(CMainFrame), RUNTIME_CLASS(CFamiTrackerView)); if (!pDocTemplate) return FALSE; if (m_pDocManager == NULL) // // // m_pDocManager = new CDocManager0CC { }; m_pDocManager->AddDocTemplate(pDocTemplate); // Work-around to enable file type registration in windows vista/7 if (IsWindowsVistaOrGreater()) { // // // HKEY HKCU; long res_reg = ::RegOpenKey(HKEY_CURRENT_USER, _T("Software\\Classes"), &HKCU); if(res_reg == ERROR_SUCCESS) RegOverridePredefKey(HKEY_CLASSES_ROOT, HKCU); } // Enable DDE Execute open EnableShellOpen(); // Skip this if in wip/beta mode #if !defined(WIP) && !defined(_DEBUG) // Add shell options RegisterShellFileTypes(); // // // static const LPCTSTR FILE_ASSOC_NAME = _T("0CC-FamiTracker Module"); AfxRegSetValue(HKEY_CLASSES_ROOT, "0CCFamiTracker.Document", REG_SZ, FILE_ASSOC_NAME, lstrlen(FILE_ASSOC_NAME) * sizeof(TCHAR)); // Add an option to play files CString strPathName, strTemp, strFileTypeId; AfxGetModuleShortFileName(AfxGetInstanceHandle(), strPathName); CString strOpenCommandLine = strPathName; strOpenCommandLine += _T(" /play \"%1\""); if (pDocTemplate->GetDocString(strFileTypeId, CDocTemplate::regFileTypeId) && !strFileTypeId.IsEmpty()) { strTemp.Format(_T("%s\\shell\\play\\%s"), (LPCTSTR)strFileTypeId, _T("command")); AfxRegSetValue(HKEY_CLASSES_ROOT, strTemp, REG_SZ, strOpenCommandLine, lstrlen(strOpenCommandLine) * sizeof(TCHAR)); } #endif // Handle command line export if (cmdInfo.m_bExport) { CCommandLineExport exporter; exporter.CommandLineExport(cmdInfo.m_strFileName, cmdInfo.m_strExportFile, cmdInfo.m_strExportLogFile, cmdInfo.m_strExportDPCMFile); ExitProcess(0); } // Dispatch commands specified on the command line. Will return FALSE if // app was launched with /RegServer, /Register, /Unregserver or /Unregister. if (!ProcessShellCommand(cmdInfo)) { if (cmdInfo.m_nShellCommand == CCommandLineInfo::AppUnregister) { // Also clear settings from registry when unregistering m_pSettings->DeleteSettings(); } return FALSE; } // Move root key back to default if (IsWindowsVistaOrGreater()) { // // // ::RegOverridePredefKey(HKEY_CLASSES_ROOT, NULL); } // The one and only window has been initialized, so show and update it m_pMainWnd->ShowWindow(m_nCmdShow); m_pMainWnd->UpdateWindow(); // call DragAcceptFiles only if there's a suffix // In an SDI app, this should occur after ProcessShellCommand // Enable drag/drop open m_pMainWnd->DragAcceptFiles(); // Initialize the sound interface, also resumes the thread if (!m_pSoundGenerator->InitializeSound(m_pMainWnd->m_hWnd)) { // If failed, restore and save default settings m_pSettings->DefaultSettings(); m_pSettings->SaveSettings(); // Quit program AfxMessageBox(IDS_START_ERROR, MB_ICONERROR); return FALSE; } // Initialize midi unit m_pMIDI->Init(); if (cmdInfo.m_bPlay) theApp.StartPlayer(MODE_PLAY); #ifdef EXPORT_TEST if (cmdInfo.m_bVerifyExport) { m_bExportTesting = true; VerifyExport(cmdInfo.m_strVerifyFile); } else { // Append menu option m_pMainWnd->GetMenu()->GetSubMenu(2)->AppendMenu(MF_SEPARATOR); m_pMainWnd->GetMenu()->GetSubMenu(2)->AppendMenu(MF_STRING, ID_MODULE_TEST_EXPORT, _T("Test exporter")); } #endif // Save the main window handle RegisterSingleInstance(); #ifndef _DEBUG m_pMainWnd->GetMenu()->GetSubMenu(4)->RemoveMenu(ID_MODULE_CHANNELS, MF_BYCOMMAND); // // // #endif if (m_pSettings->General.bCheckVersion) // // // CheckNewVersion(true); // Initialization is done TRACE("App: InitInstance done\n"); return TRUE; }