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

  1. // ATLGdiWorld.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. // Note: Proxy/Stub Information
  14. //      To build a separate proxy/stub DLL,
  15. //      run nmake -f ATLGdiWorldps.mk in the project directory.
  16.  
  17. #include "stdafx.h"
  18. #include "resource.h"
  19. #include "initguid.h"
  20. #include "ATLGdiWorld.h"
  21.  
  22. #include "ATLGdiWorld_i.c"
  23. #include "AtlTangramGdiVisual.h"
  24. #include "AtlGdiWorldImpl.h"
  25. #include "AtlEvent_i.h"
  26.  
  27. CComModule _Module;
  28.  
  29. BEGIN_OBJECT_MAP(ObjectMap)
  30.     OBJECT_ENTRY(CLSID_AtlTangramGdiVisual, CAtlTangramGdiVisual)
  31.     OBJECT_ENTRY(CLSID_AtlGdiWorld, CAtlGdiWorld)
  32. END_OBJECT_MAP()
  33.  
  34. /////////////////////////////////////////////////////////////////////////////
  35. // DLL Entry Point
  36.  
  37. extern "C"
  38. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  39. {
  40.     if (dwReason == DLL_PROCESS_ATTACH)
  41.     {
  42.         _Module.Init(ObjectMap, hInstance);
  43.         DisableThreadLibraryCalls(hInstance);
  44.     }
  45.     else if (dwReason == DLL_PROCESS_DETACH)
  46.         _Module.Term();
  47.     return TRUE;    // ok
  48. }
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // Used to determine whether the DLL can be unloaded by OLE
  52.  
  53. STDAPI DllCanUnloadNow(void)
  54. {
  55.     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  56. }
  57.  
  58. /////////////////////////////////////////////////////////////////////////////
  59. // Returns a class factory to create an object of the requested type
  60.  
  61. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  62. {
  63.     return _Module.GetClassObject(rclsid, riid, ppv);
  64. }
  65.  
  66. /////////////////////////////////////////////////////////////////////////////
  67. // DllRegisterServer - Adds entries to the system registry
  68.  
  69. STDAPI DllRegisterServer(void)
  70. {
  71.     // registers object, typelib and all interfaces in typelib
  72.     return _Module.RegisterServer(TRUE);
  73. }
  74.  
  75. /////////////////////////////////////////////////////////////////////////////
  76. // DllUnregisterServer - Removes entries from the system registry
  77.  
  78. STDAPI DllUnregisterServer(void)
  79. {
  80.     _Module.UnregisterServer();
  81.     return S_OK;
  82. }
  83.