Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

107 lines
2.5 KiB

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