home *** CD-ROM | disk | FTP | other *** search
/ Tricks of the Windows Gam…ming Gurus (2nd Edition) / Disc2.iso / msdn_vcb / samples / vc98 / sdk / winbase / security / certsvr / exit / certexit.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1997-08-19  |  2.0 KB  |  87 lines

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1996-1997
  5. //
  6. // File:        certcli.cpp
  7. //
  8. // Contents:    Cert Server Exit Module implementation
  9. //
  10. //---------------------------------------------------------------------------
  11.  
  12. #include "pch.cpp"
  13.  
  14. #pragma hdrstop
  15.  
  16. #include "exit.h"
  17.  
  18. CComModule _Module;
  19.  
  20. BEGIN_OBJECT_MAP(ObjectMap)
  21.     OBJECT_ENTRY(CLSID_CCertExit, CCertExit)
  22. END_OBJECT_MAP()
  23.  
  24.  
  25. /////////////////////////////////////////////////////////////////////////////
  26. // DLL Entry Point
  27.  
  28. extern "C"
  29. BOOL WINAPI
  30. DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*lpReserved*/)
  31. {
  32.     switch (dwReason)
  33.     {
  34.     case DLL_PROCESS_ATTACH:
  35.         _Module.Init(ObjectMap, hInstance);
  36.         DisableThreadLibraryCalls(hInstance);
  37.         break;
  38.  
  39.         case DLL_PROCESS_DETACH:
  40.         _Module.Term();
  41.             break;
  42.     }
  43.     return(TRUE);    // ok
  44. }
  45.  
  46.  
  47. /////////////////////////////////////////////////////////////////////////////
  48. // Used to determine whether the DLL can be unloaded by OLE
  49.  
  50. STDAPI
  51. DllCanUnloadNow(void)
  52. {
  53.     return(_Module.GetLockCount() == 0? S_OK : S_FALSE);
  54. }
  55.  
  56.  
  57. /////////////////////////////////////////////////////////////////////////////
  58. // Returns a class factory to create an object of the requested type
  59.  
  60. STDAPI
  61. DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  62. {
  63.     return(_Module.GetClassObject(rclsid, riid, ppv));
  64. }
  65.  
  66.  
  67. /////////////////////////////////////////////////////////////////////////////
  68. // DllRegisterServer - Adds entries to the system registry
  69.  
  70. STDAPI
  71. DllRegisterServer(void)
  72. {
  73.     // registers object, typelib and all interfaces in typelib
  74.     return(_Module.RegisterServer(TRUE));
  75. }
  76.  
  77.  
  78. /////////////////////////////////////////////////////////////////////////////
  79. // DllUnregisterServer - Removes entries from the system registry
  80.  
  81. STDAPI
  82. DllUnregisterServer(void)
  83. {
  84.     _Module.UnregisterServer();
  85.     return(S_OK);
  86. }
  87.