BOOL CServerApp::InitInstance() { #ifdef _DEBUG // turn on extra memory tracking afxMemDF |= checkAlwaysMemDF; #endif // OLE 2.0 initialization if (!AfxOleInit()) { AfxMessageBox(IDP_AFXOLEINIT_FAILED); return FALSE; } // Standard initialization LoadStdProfileSettings(); // Register document templates CDocTemplate* pDocTemplate; pDocTemplate = new CHierSvrDocTemplate; pDocTemplate->SetServerInfo( IDR_HIERSVRTYPE_SRVR_EMB, IDR_HIERSVRTYPE_SRVR_IP, RUNTIME_CLASS(CInPlaceFrame), RUNTIME_CLASS(CServerView)); AddDocTemplate(pDocTemplate); // create main MDI Frame window CMainFrame* pMainFrame = new CMainFrame; if (!pMainFrame->LoadFrame(IDR_MAINFRAME)) { delete pMainFrame; return FALSE; } m_pMainWnd = pMainFrame; // enable file manager drag/drop and DDE Execute open m_pMainWnd->DragAcceptFiles(); EnableShellOpen(); // connect the COleTemplate server to the document template m_server.ConnectTemplate(clsid, pDocTemplate, FALSE); COleTemplateServer::RegisterAll(); // Note: MDI applications register all class objects regardless of // the /Embedding on the command line. // Parse command line for standard shell commands, DDE, file open CCommandLineInfo cmdInfo; ParseCommandLine(cmdInfo); // try to launch as an OLE server if (cmdInfo.m_bRunEmbedded) { // application was run with /Embedding flag. Instead of showing // the window, the application waits to receive OLE requests. return TRUE; } m_server.UpdateRegistry(); RegisterShellFileTypes(TRUE); COleObjectFactory::UpdateRegistryAll(); // Dispatch commands specified on the command line if (!ProcessShellCommand(cmdInfo)) return FALSE; pMainFrame->ShowWindow(m_nCmdShow); pMainFrame->UpdateWindow(); return TRUE; }