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.

126 lines
3.6 KiB

  1. // McsPISag.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 McsPISag.idl by adding the following
  17. // files to the Outputs.
  18. // McsPISag_p.c
  19. // dlldata.c
  20. // To build a separate proxy/stub DLL,
  21. // run nmake -f McsPISagps.mk in the project directory.
  22. #include "stdafx.h"
  23. #include "resource.h"
  24. #include <initguid.h>
  25. #include "McsPISag.h"
  26. #include "dlldatax.h"
  27. #include "McsPI_i.c"
  28. #include "McsPISag_i.c"
  29. //#import "\bin\McsVarSetMin.tlb" no_namespace, named_guids
  30. #import "VarSet.tlb" no_namespace, named_guids rename("property", "aproperty")
  31. #include "CSvcInf.h"
  32. #include "ResStr.h"
  33. #ifdef _MERGE_PROXYSTUB
  34. extern "C" HINSTANCE hProxyDll;
  35. #endif
  36. CComModule _Module;
  37. BEGIN_OBJECT_MAP(ObjectMap)
  38. OBJECT_ENTRY(CLSID_CSvcAcctInfo, CCSvcAcctInfo)
  39. END_OBJECT_MAP()
  40. /////////////////////////////////////////////////////////////////////////////
  41. // DLL Entry Point
  42. StringLoader gString;
  43. extern "C"
  44. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  45. {
  46. lpReserved;
  47. #ifdef _MERGE_PROXYSTUB
  48. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  49. return FALSE;
  50. #endif
  51. if (dwReason == DLL_PROCESS_ATTACH)
  52. {
  53. ATLTRACE(_T("{McsPISag.dll}DllMain(hInstance=0x%08lX, dwReason=DLL_PROCESS_ATTACH,...)\n"), hInstance);
  54. _Module.Init(ObjectMap, hInstance, &LIBID_MCSPISAGLib);
  55. DisableThreadLibraryCalls(hInstance);
  56. _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF|_CRTDBG_LEAK_CHECK_DF);
  57. }
  58. else if (dwReason == DLL_PROCESS_DETACH)
  59. {
  60. ATLTRACE(_T("{McsPISag.dll}DllMain(hInstance=0x%08lX, dwReason=DLL_PROCESS_DETACH,...)\n"), hInstance);
  61. _Module.Term();
  62. }
  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. }