home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / com / inproc / server / inproc.cpp < prev    next >
C/C++ Source or Header  |  1998-04-02  |  3KB  |  102 lines

  1. // inproc.cpp : Defines the class behaviors for the application.
  2. //
  3. // This is a part of the Microsoft Foundation Classes C++ library.
  4. // Copyright (C) 1992-1995 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Microsoft Foundation Classes Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Microsoft Foundation Classes product.
  12.  
  13. #include "stdafx.h"
  14. #include "inproc.h"
  15.  
  16. #ifdef _DEBUG
  17. #undef THIS_FILE
  18. static char BASED_CODE THIS_FILE[] = __FILE__;
  19. #endif
  20.  
  21. /////////////////////////////////////////////////////////////////////////////
  22. // CInProcApp
  23.  
  24. BEGIN_MESSAGE_MAP(CInProcApp, CWinApp)
  25.     //{{AFX_MSG_MAP(CInProcApp)
  26.         // NOTE - the ClassWizard will add and remove mapping macros here.
  27.         //    DO NOT EDIT what you see in these blocks of generated code!
  28.     //}}AFX_MSG_MAP
  29. END_MESSAGE_MAP()
  30.  
  31. /////////////////////////////////////////////////////////////////////////////
  32. // CInProcApp construction
  33.  
  34. CInProcApp::CInProcApp()
  35. {
  36.     // TODO: add construction code here,
  37.     // Place all significant initialization in InitInstance
  38. }
  39.  
  40. /////////////////////////////////////////////////////////////////////////////
  41. // The one and only CInProcApp object
  42.  
  43. CInProcApp NEAR theApp;
  44.  
  45. /////////////////////////////////////////////////////////////////////////////
  46. // CInProcApp initialization
  47.  
  48. BOOL CInProcApp::InitInstance()
  49. {
  50. #ifndef _USRDLL
  51.     if (!RunEmbedded() && !RunAutomated())
  52.     {
  53.         Enable3dControls();
  54.  
  55.         COleObjectFactory::UpdateRegistryAll();
  56.  
  57.         AfxMessageBox(IDP_CANT_RUN_STANDALONE);
  58.         return FALSE;
  59.     }
  60.  
  61.     // Initialize OLE libraries
  62.     if (!AfxOleInit())
  63.     {
  64.         Enable3dControls();
  65.  
  66.         AfxMessageBox(IDP_OLE_INIT_FAILED);
  67.         return FALSE;
  68.     }
  69. #endif
  70.  
  71.     // Register all OLE server (factories) as running.  This enables the
  72.     //  OLE libraries to create objects from other applications.
  73.     COleObjectFactory::RegisterAll();
  74.  
  75.     return TRUE;
  76. }
  77.  
  78. /////////////////////////////////////////////////////////////////////////////
  79. // Special entry points required for inproc servers
  80.  
  81. #ifdef _USRDLL
  82. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  83. {
  84.     return AfxDllGetClassObject(rclsid, riid, ppv);
  85. }
  86.  
  87. STDAPI DllCanUnloadNow(void)
  88. {
  89.     return AfxDllCanUnloadNow();
  90. }
  91.  
  92. // by exporting DllRegisterServer, you can use regsvr.exe
  93. STDAPI DllRegisterServer(void)
  94. {
  95.     COleObjectFactory::UpdateRegistryAll();
  96.     return S_OK;
  97. }
  98. #endif //_USRDLL
  99.  
  100. /////////////////////////////////////////////////////////////////////////////
  101. // CInProcApp commands
  102.