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.

128 lines
3.6 KiB

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