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.

114 lines
3.1 KiB

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