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.4 KiB

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