Leaked source code of windows server 2003
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.

149 lines
3.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: scrdenrl.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. // scrdenrl.cpp : Implementation of DLL Exports.
  11. // Note: Proxy/Stub Information
  12. // To merge the proxy/stub code into the object DLL, add the file
  13. // dlldatax.c to the project. Make sure precompiled headers
  14. // are turned off for this file, and add _MERGE_PROXYSTUB to the
  15. // defines for the project.
  16. //
  17. // If you are not running WinNT4.0 or Win95 with DCOM, then you
  18. // need to remove the following define from dlldatax.c
  19. // #define _WIN32_WINNT 0x0400
  20. //
  21. // Further, if you are running MIDL without /Oicf switch, you also
  22. // need to remove the following define from dlldatax.c.
  23. // #define USE_STUBLESS_PROXY
  24. //
  25. // Modify the custom build rule for scrdenrl.idl by adding the following
  26. // files to the Outputs.
  27. // scrdenrl_p.c
  28. // dlldata.c
  29. // To build a separate proxy/stub DLL,
  30. // run nmake -f scrdenrlps.mk in the project directory.
  31. #include <stdafx.h>
  32. #include <comcat.h>
  33. #include <objsafe.h>
  34. #include "resource.h"
  35. #include "initguid.h"
  36. #include "scrdenrl.h"
  37. #include "SCrdEnr.h"
  38. /*#ifdef _MERGE_PROXYSTUB
  39. extern "C" HINSTANCE hProxyDll;
  40. #endif*/
  41. CComModule _Module;
  42. BEGIN_OBJECT_MAP(ObjectMap)
  43. OBJECT_ENTRY(CLSID_SCrdEnr, CSCrdEnr)
  44. END_OBJECT_MAP()
  45. /////////////////////////////////////////////////////////////////////////////
  46. // DLL Entry Point
  47. extern "C"
  48. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  49. {
  50. lpReserved;
  51. /*#ifdef _MERGE_PROXYSTUB
  52. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  53. return FALSE;
  54. #endif */
  55. if (dwReason == DLL_PROCESS_ATTACH)
  56. {
  57. _Module.Init(ObjectMap, hInstance);
  58. DisableThreadLibraryCalls(hInstance);
  59. }
  60. else if (dwReason == DLL_PROCESS_DETACH)
  61. _Module.Term();
  62. return TRUE; // ok
  63. }
  64. /////////////////////////////////////////////////////////////////////////////
  65. // Used to determine whether the DLL can be unloaded by OLE
  66. STDAPI DllCanUnloadNow(void)
  67. {
  68. /*#ifdef _MERGE_PROXYSTUB
  69. if (PrxDllCanUnloadNow() != S_OK)
  70. return S_FALSE;
  71. #endif */
  72. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  73. }
  74. /////////////////////////////////////////////////////////////////////////////
  75. // Returns a class factory to create an object of the requested type
  76. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  77. {
  78. /*#ifdef _MERGE_PROXYSTUB
  79. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  80. return S_OK;
  81. #endif */
  82. return _Module.GetClassObject(rclsid, riid, ppv);
  83. }
  84. /////////////////////////////////////////////////////////////////////////////
  85. // DllRegisterServer - Adds entries to the system registry
  86. STDAPI DllRegisterServer(void)
  87. {
  88. /*#ifdef _MERGE_PROXYSTUB
  89. HRESULT hRes = PrxDllRegisterServer();
  90. if (FAILED(hRes))
  91. return hRes;
  92. #endif*/
  93. HRESULT hRes=S_OK;
  94. BOOL fInitialize=FALSE;
  95. hRes= _Module.RegisterServer(TRUE);
  96. if(!FAILED(CoInitialize(NULL)))
  97. fInitialize=TRUE;
  98. if(fInitialize)
  99. CoUninitialize();
  100. return hRes;
  101. }
  102. /////////////////////////////////////////////////////////////////////////////
  103. // DllUnregisterServer - Removes entries from the system registry
  104. STDAPI DllUnregisterServer(void)
  105. {
  106. /*#ifdef _MERGE_PROXYSTUB
  107. PrxDllUnregisterServer();
  108. #endif */
  109. BOOL fInitialize=FALSE;
  110. if(!FAILED(CoInitialize(NULL)))
  111. fInitialize=TRUE;
  112. if(fInitialize)
  113. CoUninitialize();
  114. _Module.UnregisterServer();
  115. return S_OK;
  116. }