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.

123 lines
3.4 KiB

  1. // MSAAText.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 MSAAText.idl by adding the following
  17. // files to the Outputs.
  18. // MSAAText_p.c
  19. // dlldata.c
  20. // To build a separate proxy/stub DLL,
  21. // run nmake -f MSAATextps.mk in the project directory.
  22. #include "stdafx.h"
  23. #include "resource.h"
  24. #include <initguid.h>
  25. #include "MSAAText.h"
  26. #include "dlldatax.h"
  27. #include "MSAAStore.h"
  28. #include "MSAAAdapter.h"
  29. #include "MSAAClientAdapter.h"
  30. #include "Dict.h"
  31. #include "DocWrap.h"
  32. #include <TextStor.h>
  33. #include <msctfx.h>
  34. #ifdef _MERGE_PROXYSTUB
  35. extern "C" HINSTANCE hProxyDll;
  36. #endif
  37. CComModule _Module;
  38. BEGIN_OBJECT_MAP(ObjectMap)
  39. OBJECT_ENTRY(CLSID_AccStore, CAccStore)
  40. OBJECT_ENTRY(CLSID_AccServerDocMgr, CAccServerDocMgr)
  41. OBJECT_ENTRY(CLSID_AccClientDocMgr, CAccClientDocMgr)
  42. OBJECT_ENTRY(CLSID_AccDictionary, CDict)
  43. OBJECT_ENTRY(CLSID_DocWrap, CDocWrap)
  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, &LIBID_MSAATEXTLib);
  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. // registers object, typelib and all interfaces in typelib
  94. return _Module.RegisterServer(TRUE);
  95. }
  96. /////////////////////////////////////////////////////////////////////////////
  97. // DllUnregisterServer - Removes entries from the system registry
  98. STDAPI DllUnregisterServer(void)
  99. {
  100. #ifdef _MERGE_PROXYSTUB
  101. PrxDllUnregisterServer();
  102. #endif
  103. return _Module.UnregisterServer(TRUE);
  104. }