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

  1. // COMMap.cpp : Implementation of DLL Exports.
  2. //
  3. // This is a part of the Active Template Library.
  4. // Copyright (C) 1996-1998 Microsoft Corporation
  5. // All rights reserved.
  6. //
  7. // This source code is only intended as a supplement to the
  8. // Active Template Library Reference and related
  9. // electronic documentation provided with the library.
  10. // See these sources for detailed information regarding the
  11. // Active Template Library product.
  12. //
  13. // You will need the NT SUR Beta 2 SDK or VC 4.2 in order to build this
  14. // project.  This is because you will need MIDL 3.00.15 or higher and new
  15. // headers and libs.  If you have VC 4.2 installed, then everything should
  16. // already be configured correctly.
  17.  
  18. // Note: Proxy/Stub Information
  19. //      To build a separate proxy/stub DLL,
  20. //      run nmake -f COMMapps.mak in the project directory.
  21.  
  22. #include "premap.h"
  23. #include "mapres.h"
  24. #include "initguid.h"
  25. #include "COMMap.h"
  26. #include "Outer.h"
  27.  
  28. #define IID_DEFINED
  29. #include "COMMap_i.c"
  30.  
  31. #define IID_DEFINED
  32. #include "aggreg\aggreg_i.c"
  33.  
  34.  
  35.  
  36. CComModule _Module;
  37.  
  38. BEGIN_OBJECT_MAP(ObjectMap)
  39.     OBJECT_ENTRY(CLSID_COuter, COuter)
  40.     OBJECT_ENTRY(CLSID_CChain, CChain)
  41. END_OBJECT_MAP()
  42.  
  43. /////////////////////////////////////////////////////////////////////////////
  44. // DLL Entry Point
  45.  
  46. extern "C"
  47. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  48. {
  49.     if (dwReason == DLL_PROCESS_ATTACH)
  50.     {
  51.         _Module.Init(ObjectMap, hInstance);
  52.         DisableThreadLibraryCalls(hInstance);
  53.     }
  54.     else if (dwReason == DLL_PROCESS_DETACH)
  55.         _Module.Term();
  56.     return TRUE;    // ok
  57. }
  58.  
  59. /////////////////////////////////////////////////////////////////////////////
  60. // Used to determine whether the DLL can be unloaded by OLE
  61.  
  62. STDAPI DllCanUnloadNow(void)
  63. {
  64.     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  65. }
  66.  
  67. /////////////////////////////////////////////////////////////////////////////
  68. // Returns a class factory to create an object of the requested type
  69.  
  70. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  71. {
  72.     return _Module.GetClassObject(rclsid, riid, ppv);
  73. }
  74.  
  75. /////////////////////////////////////////////////////////////////////////////
  76. // DllRegisterServer - Adds entries to the system registry
  77.  
  78. STDAPI DllRegisterServer(void)
  79. {
  80.     // registers object, typelib and all interfaces in typelib
  81.     return _Module.RegisterServer(TRUE);
  82. }
  83.  
  84. /////////////////////////////////////////////////////////////////////////////
  85. // DllUnregisterServer - Removes entries from the system registry
  86.  
  87. STDAPI DllUnregisterServer(void)
  88. {
  89.     _Module.UnregisterServer();
  90.     return S_OK;
  91. }
  92.