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

  1. // ActiveDoc.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 or newer in order
  14. // to build this project.  This is because you will need MIDL 3.00.15
  15. // or higher and new headers and libs. If you have VC 4.2 or newer
  16. // installed, then everything should already be configured correctly.
  17.  
  18. // Note: Proxy/Stub Information
  19. //      To build a separate proxy/stub DLL,
  20. //      run nmake -f ActiveDocps.mak in the project directory.
  21.  
  22. #include "stdafx.h"
  23. #include "resource.h"
  24. #include "initguid.h"
  25. #include "ActiveDoc.h"
  26.  
  27. #define IID_DEFINED
  28. #include "ActiveDoc_i.c"
  29. #include "ActiveCtl.h"
  30.  
  31. CComModule _Module;
  32.  
  33. BEGIN_OBJECT_MAP(ObjectMap)
  34.     OBJECT_ENTRY(CLSID_CActiveDoc, CActiveDoc)
  35. END_OBJECT_MAP()
  36.  
  37. /////////////////////////////////////////////////////////////////////////////
  38. // DLL Entry Point
  39.  
  40. extern "C"
  41. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason,
  42.     LPVOID /*lpReserved*/)
  43. {
  44.     if (dwReason == DLL_PROCESS_ATTACH)
  45.     {
  46.         _Module.Init(ObjectMap, hInstance);
  47.         DisableThreadLibraryCalls(hInstance);
  48.     }
  49.     else if (dwReason == DLL_PROCESS_DETACH)
  50.         _Module.Term();
  51.  
  52.     return TRUE;
  53. }
  54.  
  55. /////////////////////////////////////////////////////////////////////////////
  56. // Used to determine whether the DLL can be unloaded by OLE
  57.  
  58. STDAPI DllCanUnloadNow(void)
  59. {
  60.     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  61. }
  62.  
  63. /////////////////////////////////////////////////////////////////////////////
  64. // Returns a class factory to create an object of the requested type
  65.  
  66. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  67. {
  68.     return _Module.GetClassObject(rclsid, riid, ppv);
  69. }
  70.  
  71. /////////////////////////////////////////////////////////////////////////////
  72. // DllRegisterServer - Adds entries to the system registry
  73.  
  74. STDAPI DllRegisterServer(void)
  75. {
  76.     // registers object, typelib and all interfaces in typelib
  77.     return _Module.RegisterServer(TRUE);
  78. }
  79.  
  80. /////////////////////////////////////////////////////////////////////////////
  81. // DllUnregisterServer - Removes entries from the system registry
  82.  
  83. STDAPI DllUnregisterServer(void)
  84. {
  85.     _Module.UnregisterServer();
  86.     return S_OK;
  87. }
  88.