MDApp::MDApp() : net_(PathForResource("mdnet.ntwk")) { has_been_initialized_ = false; useBatch_ = true; }
BOOL CPrinterSetupWizardApp::InitInstance() { CString errorMessage; CString errorCaption; wchar_t resource[MAX_PATH]; int res; OSStatus err = kNoErr; // // initialize the debugging framework // debug_initialize( kDebugOutputTypeWindowsDebugger, "PrinterSetupWizard", NULL ); debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelTrace ); // Before we load the resources, let's load the error string errorMessage.LoadString( IDS_REINSTALL ); errorCaption.LoadString( IDS_REINSTALL_CAPTION ); // Load Resources res = PathForResource( NULL, L"RendezvousPrinterWizard.dll", resource, MAX_PATH ); err = translate_errno( res != 0, kUnknownErr, kUnknownErr ); require_noerr( err, exit ); g_nonLocalizedResources = LoadLibrary( resource ); translate_errno( g_nonLocalizedResources, GetLastError(), kUnknownErr ); require_noerr( err, exit ); res = PathForResource( NULL, L"RendezvousPrinterWizardLocalized.dll", resource, MAX_PATH ); err = translate_errno( res != 0, kUnknownErr, kUnknownErr ); require_noerr( err, exit ); g_localizedResources = LoadLibrary( resource ); translate_errno( g_localizedResources, GetLastError(), kUnknownErr ); require_noerr( err, exit ); AfxSetResourceHandle( g_localizedResources ); // 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(); CWinApp::InitInstance(); AfxEnableControlContainer(); { CPrinterSetupWizardSheet dlg(IDS_CAPTION); m_pMainWnd = &dlg; try { INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } } catch (CPrinterSetupWizardSheet::WizardException & exc) { MessageBox(NULL, exc.text, exc.caption, MB_OK|MB_ICONEXCLAMATION); } } exit: if ( err ) { MessageBox( NULL, errorMessage, errorCaption, MB_ICONERROR | MB_OK ); } if ( g_nonLocalizedResources ) { FreeLibrary( g_nonLocalizedResources ); } if ( g_localizedResources ) { FreeLibrary( g_localizedResources ); } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }
BOOL CCPApp::InitInstance() { CCommandLineInfo commandLine; wchar_t resource[MAX_PATH]; CString errorMessage; CString errorCaption; int res; OSStatus err = kNoErr; HeapSetInformation( NULL, HeapEnableTerminationOnCorruption, NULL, 0 ); // // initialize the debugging framework // debug_initialize( kDebugOutputTypeWindowsDebugger, "ControlPanel", NULL ); debug_set_property( kDebugPropertyTagPrintLevel, kDebugLevelTrace ); // Before we load the resources, let's load the error string errorMessage.LoadString( IDS_REINSTALL ); errorCaption.LoadString( IDS_REINSTALL_CAPTION ); res = PathForResource( NULL, L"ControlPanelResources.dll", resource, MAX_PATH ); err = translate_errno( res != 0, kUnknownErr, kUnknownErr ); require_noerr( err, exit ); g_nonLocalizedResources = LoadLibrary( resource ); translate_errno( g_nonLocalizedResources, GetLastError(), kUnknownErr ); require_noerr( err, exit ); res = PathForResource( NULL, L"ControlPanelLocalized.dll", resource, MAX_PATH ); err = translate_errno( res != 0, kUnknownErr, kUnknownErr ); require_noerr( err, exit ); g_localizedResources = LoadLibrary( resource ); translate_errno( g_localizedResources, GetLastError(), kUnknownErr ); require_noerr( err, exit ); AfxSetResourceHandle( g_localizedResources ); // 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(); CWinApp::InitInstance(); AfxEnableControlContainer(); ParseCommandLine( commandLine ); if ( commandLine.m_nShellCommand == CCommandLineInfo::AppRegister ) { CString localizedName; CString toolTip; TCHAR iconPath[ MAX_PATH + 12 ] = TEXT( "" ); TCHAR exePath[ MAX_PATH ] = TEXT( "" ); DWORD nChars; OSStatus err; nChars = GetModuleFileName( NULL, exePath, sizeof_array( exePath ) ); err = translate_errno( nChars > 0, (OSStatus) GetLastError(), kUnknownErr ); require_noerr( err, exit ); wsprintf( iconPath, L"%s,-%d", exePath, IDR_APPLET ); localizedName.LoadString( IDS_APPLET_NAME ); toolTip.LoadString( IDS_APPLET_TOOLTIP ); Register( g_controlPanelGUID, g_controlPanelName, g_controlPanelCanonicalName, g_controlPanelCategory, localizedName, toolTip, iconPath, exePath ); } else if ( commandLine.m_nShellCommand == CCommandLineInfo::AppUnregister ) { Unregister( g_controlPanelGUID ); } else { CString name; CConfigPropertySheet dlg; name.LoadString( IDR_APPLET ); dlg.Construct( name, NULL, 0 ); m_pMainWnd = &dlg; try { INT_PTR nResponse = dlg.DoModal(); if (nResponse == IDOK) { // TODO: Place code here to handle when the dialog is // dismissed with OK } else if (nResponse == IDCANCEL) { // TODO: Place code here to handle when the dialog is // dismissed with Cancel } } catch (...) { MessageBox(NULL, L"", L"", MB_OK|MB_ICONEXCLAMATION); } } if ( err ) { MessageBox( NULL, L"", L"", MB_ICONERROR | MB_OK ); } exit: if ( err ) { MessageBox( NULL, errorMessage, errorCaption, MB_ICONERROR | MB_OK ); } // Since the dialog has been closed, return FALSE so that we exit the // application, rather than start the application's message pump. return FALSE; }