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.

136 lines
3.8 KiB

  1. /*---------------------------------------------------------------------------
  2. File: McsClosedSet.cpp
  3. Comments: DLL exports for closed set detector COM object. This file is mostly
  4. 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. */// McsClosedSet.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 McsClosedSet.idl by adding the following
  27. // files to the Outputs.
  28. // McsClosedSet_p.c
  29. // dlldata.c
  30. // To build a separate proxy/stub DLL,
  31. // run nmake -f McsClosedSetps.mk in the project directory.
  32. #include "stdafx.h"
  33. #include "resource.h"
  34. #include <initguid.h>
  35. #include "ClSet.h"
  36. #include "dlldatax.h"
  37. #include "ClSet_i.c"
  38. #include "Detector.h"
  39. #ifdef _MERGE_PROXYSTUB
  40. extern "C" HINSTANCE hProxyDll;
  41. #endif
  42. #include "ErrDct.hpp"
  43. #include "ResStr.h"
  44. TErrorDct err;
  45. TError & errCommon = err;
  46. StringLoader gString;
  47. CComModule _Module;
  48. BEGIN_OBJECT_MAP(ObjectMap)
  49. OBJECT_ENTRY(CLSID_SetDetector, CSetDetector)
  50. END_OBJECT_MAP()
  51. /////////////////////////////////////////////////////////////////////////////
  52. // DLL Entry Point
  53. extern "C"
  54. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  55. {
  56. lpReserved;
  57. #ifdef _MERGE_PROXYSTUB
  58. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  59. return FALSE;
  60. #endif
  61. if (dwReason == DLL_PROCESS_ATTACH)
  62. {
  63. _Module.Init(ObjectMap, hInstance, &LIBID_MCSCLOSEDSETLib);
  64. DisableThreadLibraryCalls(hInstance);
  65. }
  66. else if (dwReason == DLL_PROCESS_DETACH)
  67. _Module.Term();
  68. return TRUE; // ok
  69. }
  70. /////////////////////////////////////////////////////////////////////////////
  71. // Used to determine whether the DLL can be unloaded by OLE
  72. STDAPI DllCanUnloadNow(void)
  73. {
  74. #ifdef _MERGE_PROXYSTUB
  75. if (PrxDllCanUnloadNow() != S_OK)
  76. return S_FALSE;
  77. #endif
  78. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  79. }
  80. /////////////////////////////////////////////////////////////////////////////
  81. // Returns a class factory to create an object of the requested type
  82. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  83. {
  84. #ifdef _MERGE_PROXYSTUB
  85. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  86. return S_OK;
  87. #endif
  88. return _Module.GetClassObject(rclsid, riid, ppv);
  89. }
  90. /////////////////////////////////////////////////////////////////////////////
  91. // DllRegisterServer - Adds entries to the system registry
  92. STDAPI DllRegisterServer(void)
  93. {
  94. #ifdef _MERGE_PROXYSTUB
  95. HRESULT hRes = PrxDllRegisterServer();
  96. if (FAILED(hRes))
  97. return hRes;
  98. #endif
  99. // registers object, typelib and all interfaces in typelib
  100. return _Module.RegisterServer(TRUE);
  101. }
  102. /////////////////////////////////////////////////////////////////////////////
  103. // DllUnregisterServer - Removes entries from the system registry
  104. STDAPI DllUnregisterServer(void)
  105. {
  106. #ifdef _MERGE_PROXYSTUB
  107. PrxDllUnregisterServer();
  108. #endif
  109. return _Module.UnregisterServer(TRUE);
  110. }