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.

120 lines
3.3 KiB

  1. // TaskUI.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 TaskUI.idl by adding the following
  17. // files to the Outputs.
  18. // TaskUI_p.c
  19. // dlldata.c
  20. // To build a separate proxy/stub DLL,
  21. // run nmake -f TaskUIps.mk in the project directory.
  22. #include "stdafx.h"
  23. #include "resource.h"
  24. #include <initguid.h>
  25. #include "TaskUI.h"
  26. #include "dlldatax.h"
  27. #include "TaskUI_i.c"
  28. #include "TaskSheet.h"
  29. #include "TaskFrame.h"
  30. #include "HTMLControl.h"
  31. #ifdef _MERGE_PROXYSTUB
  32. extern "C" HINSTANCE hProxyDll;
  33. #endif
  34. HACCEL g_hAccel = NULL;
  35. CComModule _Module;
  36. BEGIN_OBJECT_MAP(ObjectMap)
  37. OBJECT_ENTRY(CLSID_TaskSheet, CTaskSheet)
  38. OBJECT_ENTRY(CLSID_TaskUI_HTMLControl, CTaskUI_HTMLControl)
  39. END_OBJECT_MAP()
  40. /////////////////////////////////////////////////////////////////////////////
  41. // DLL Entry Point
  42. extern "C"
  43. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  44. {
  45. lpReserved;
  46. #ifdef _MERGE_PROXYSTUB
  47. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  48. return FALSE;
  49. #endif
  50. if (dwReason == DLL_PROCESS_ATTACH)
  51. {
  52. _Module.Init(ObjectMap, hInstance, &LIBID_TASKUILib);
  53. DisableThreadLibraryCalls(hInstance);
  54. g_hAccel = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_ACCEL));
  55. }
  56. else if (dwReason == DLL_PROCESS_DETACH)
  57. _Module.Term();
  58. return TRUE; // ok
  59. }
  60. /////////////////////////////////////////////////////////////////////////////
  61. // Used to determine whether the DLL can be unloaded by OLE
  62. STDAPI DllCanUnloadNow(void)
  63. {
  64. #ifdef _MERGE_PROXYSTUB
  65. if (PrxDllCanUnloadNow() != S_OK)
  66. return S_FALSE;
  67. #endif
  68. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  69. }
  70. /////////////////////////////////////////////////////////////////////////////
  71. // Returns a class factory to create an object of the requested type
  72. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  73. {
  74. #ifdef _MERGE_PROXYSTUB
  75. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  76. return S_OK;
  77. #endif
  78. return _Module.GetClassObject(rclsid, riid, ppv);
  79. }
  80. /////////////////////////////////////////////////////////////////////////////
  81. // DllRegisterServer - Adds entries to the system registry
  82. STDAPI DllRegisterServer(void)
  83. {
  84. #ifdef _MERGE_PROXYSTUB
  85. HRESULT hRes = PrxDllRegisterServer();
  86. if (FAILED(hRes))
  87. return hRes;
  88. #endif
  89. // registers object, typelib and all interfaces in typelib
  90. return _Module.RegisterServer(TRUE);
  91. }
  92. /////////////////////////////////////////////////////////////////////////////
  93. // DllUnregisterServer - Removes entries from the system registry
  94. STDAPI DllUnregisterServer(void)
  95. {
  96. #ifdef _MERGE_PROXYSTUB
  97. PrxDllUnregisterServer();
  98. #endif
  99. return _Module.UnregisterServer(TRUE);
  100. }