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

  1. // CDInfo.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 higher 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 installed,
  16. // 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 CDInfops.mak in the project directory.
  21.  
  22. #include "stdafx.h"
  23. #include "resource.h"
  24. #include "initguid.h"
  25. #include "CDInfo.h"
  26.  
  27. #define IID_DEFINED
  28. #include "CDInfo_i.c"
  29. #include "CDInfo1.h"
  30.  
  31.  
  32. CComModule _Module;
  33.  
  34. BEGIN_OBJECT_MAP(ObjectMap)
  35.     OBJECT_ENTRY(CLSID_CCDInfo, CCDInfo)
  36. END_OBJECT_MAP()
  37.  
  38. /////////////////////////////////////////////////////////////////////////////
  39. // DLL Entry Point
  40.  
  41. extern "C"
  42. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, 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.     return TRUE;    // ok
  52. }
  53.  
  54. /////////////////////////////////////////////////////////////////////////////
  55. // Used to determine whether the DLL can be unloaded by OLE
  56.  
  57. STDAPI DllCanUnloadNow(void)
  58. {
  59.     return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  60. }
  61.  
  62. /////////////////////////////////////////////////////////////////////////////
  63. // Returns a class factory to create an object of the requested type
  64.  
  65. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  66. {
  67.     return _Module.GetClassObject(rclsid, riid, ppv);
  68. }
  69.  
  70. /////////////////////////////////////////////////////////////////////////////
  71. // DllRegisterServer - Adds entries to the system registry
  72.  
  73. STDAPI DllRegisterServer(void)
  74. {
  75.     // registers object, typelib and all interfaces in typelib
  76.     return _Module.RegisterServer(TRUE);
  77. }
  78.  
  79. /////////////////////////////////////////////////////////////////////////////
  80. // DllUnregisterServer - Removes entries from the system registry
  81.  
  82. STDAPI DllUnregisterServer(void)
  83. {
  84.     _Module.UnregisterServer();
  85.     return S_OK;
  86. }
  87.