home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / com / connect / mdrive / mdrive.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1998-04-03  |  2.8 KB  |  96 lines

  1. // MDrive.cpp : Defines the class behaviors for the application.
  2. //
  3.  
  4. #include "premdriv.h"
  5. #include "MDrive.h"
  6. #include "DriveDlg.h"
  7.  
  8. #ifdef _DEBUG
  9. #define new DEBUG_NEW
  10. #undef THIS_FILE
  11. static char THIS_FILE[] = __FILE__;
  12. #endif
  13.  
  14. /////////////////////////////////////////////////////////////////////////////
  15. // CMDriveApp
  16.  
  17. BEGIN_MESSAGE_MAP(CMDriveApp, CWinApp)
  18.     //{{AFX_MSG_MAP(CMDriveApp)
  19.         // NOTE - the ClassWizard will add and remove mapping macros here.
  20.         //    DO NOT EDIT what you see in these blocks of generated code!
  21.     //}}AFX_MSG
  22.     ON_COMMAND(ID_HELP, CWinApp::OnHelp)
  23. END_MESSAGE_MAP()
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // CMDriveApp construction
  27.  
  28. CMDriveApp::CMDriveApp()
  29. {
  30.     // TODO: add construction code here,
  31.     // Place all significant initialization in InitInstance
  32. }
  33.  
  34. /////////////////////////////////////////////////////////////////////////////
  35. // The one and only CMDriveApp object
  36.  
  37. CMDriveApp theApp;
  38.  
  39. /////////////////////////////////////////////////////////////////////////////
  40. // CMDriveApp initialization
  41.  
  42. BOOL CMDriveApp::InitInstance()
  43. {
  44.     // Initialize OLE libraries -- free threaded
  45.     HRESULT hRes = CoInitializeEx(NULL, COINIT_MULTITHREADED);
  46.     //if (!AfxOleInit())
  47.     if (FAILED(hRes))
  48.     {
  49.         AfxMessageBox(IDP_OLE_INIT_FAILED);
  50.         return FALSE;
  51.     }
  52.  
  53.     // Standard initialization
  54.     // If you are not using these features and wish to reduce the size
  55.     //  of your final executable, you should remove from the following
  56.     //  the specific initialization routines you do not need.
  57.  
  58. #ifdef _AFXDLL
  59.     Enable3dControls();         // Call this when using MFC in a shared DLL
  60. #else
  61.     Enable3dControlsStatic();   // Call this when linking to MFC statically
  62. #endif
  63.  
  64.     // Parse the command line to see if launched as OLE server
  65.     if (RunEmbedded() || RunAutomated())
  66.     {
  67.         // Register all OLE server (factories) as running.  This enables the
  68.         //  OLE libraries to create objects from other applications.
  69.         COleTemplateServer::RegisterAll();
  70.  
  71.         // Application was run with /Embedding or /Automation.  Don't show the
  72.         //  main window in this case.
  73.         return TRUE;
  74.     }
  75.  
  76.     // When a server application is launched stand-alone, it is a good idea
  77.     //  to update the system registry in case it has been damaged.
  78.     COleObjectFactory::UpdateRegistryAll();
  79.  
  80.     CMDriveDlg dlg;
  81.     m_pMainWnd = &dlg;
  82.     int nResponse = dlg.DoModal();
  83.     if (nResponse == IDOK)
  84.     {
  85. //      dlg.OnStopAll();
  86.     }
  87.     else if (nResponse == IDCANCEL)
  88.     {
  89. //      dlg.OnStopAll();
  90.     }
  91.  
  92.     // Since the dialog has been closed, return FALSE so that we exit the
  93.     //  application, rather than start the application's message pump.
  94.     return FALSE;
  95. }
  96.