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

  1. // minimal.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. #include "premin.h"
  14.  
  15. #include <initguid.h>
  16. #include "minimal.h"
  17.  
  18. #include "MinObj.h"
  19.  
  20. CComModule _Module;
  21.  
  22. BEGIN_OBJECT_MAP(ObjectMap)
  23.     OBJECT_ENTRY(CLSID_CMinObj, CMinObj)
  24. END_OBJECT_MAP()
  25.  
  26. /////////////////////////////////////////////////////////////////////////////
  27. // DLL Entry Point
  28.  
  29. extern "C"
  30. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  31. {
  32.     if (dwReason == DLL_PROCESS_ATTACH)
  33.     {
  34.         _Module.Init(ObjectMap, hInstance);
  35.         //DisableThreadLibraryCalls(hInstance);
  36.     }
  37.     else if (dwReason == DLL_PROCESS_DETACH)
  38.         _Module.Term();
  39.     return TRUE;    // ok
  40. }
  41.  
  42. /////////////////////////////////////////////////////////////////////////////
  43. // Used to determine whether the DLL can be unloaded by OLE
  44.  
  45. STDAPI DllCanUnloadNow(void)
  46. {
  47.     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  48. }
  49.  
  50. /////////////////////////////////////////////////////////////////////////////
  51. // Returns a class factory to create an object of the requested type
  52.  
  53. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  54. {
  55.     return _Module.GetClassObject(rclsid, riid, ppv);
  56. }
  57.