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.

108 lines
3.0 KiB

  1. //=======================================================================
  2. //
  3. // Copyright (C) Microsoft Corporation, 1998 - 1999 All Rights Reserved.
  4. //
  5. // File: WUpdInfo.cpp : Implementation of DLL Exports.
  6. //
  7. // Note: Proxy/Stub Information
  8. // To merge the proxy/stub code into the object DLL, add the file
  9. // dlldatax.c to the project. Make sure precompiled headers
  10. // are turned off for this file, and add _MERGE_PROXYSTUB to the
  11. // defines for the project.
  12. //
  13. // If you are not running WinNT4.0 or Win95 with DCOM, then you
  14. // need to remove the following define from dlldatax.c
  15. // #define _WIN32_WINNT 0x0400
  16. //
  17. // Further, if you are running MIDL without /Oicf switch, you also
  18. // need to remove the following define from dlldatax.c.
  19. // #define USE_STUBLESS_PROXY
  20. //
  21. // Modify the custom build rule for WUpdInfo.idl by adding the following
  22. // files to the Outputs.
  23. // WUpdInfo_p.c
  24. // dlldata.c
  25. // To build a separate proxy/stub DLL,
  26. // run nmake -f WUpdInfops.mk in the project directory.
  27. //
  28. //=======================================================================
  29. #include "stdafx.h"
  30. #include "resource.h"
  31. #include "initguid.h"
  32. #include "WUpdInfo.h"
  33. #include "dlldatax.h"
  34. #include "WUpdInfo_i.c"
  35. #include "CWUpd.h"
  36. #ifdef _MERGE_PROXYSTUB
  37. extern "C" HINSTANCE hProxyDll;
  38. #endif
  39. CComModule _Module;
  40. BEGIN_OBJECT_MAP(ObjectMap)
  41. OBJECT_ENTRY(CLSID_CWUpdInfo, CCWUpdInfo)
  42. END_OBJECT_MAP()
  43. /////////////////////////////////////////////////////////////////////////////
  44. // DLL Entry Point
  45. extern "C"
  46. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  47. {
  48. lpReserved;
  49. #ifdef _MERGE_PROXYSTUB
  50. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  51. return FALSE;
  52. #endif
  53. if (dwReason == DLL_PROCESS_ATTACH)
  54. {
  55. _Module.Init(ObjectMap, hInstance);
  56. DisableThreadLibraryCalls(hInstance);
  57. }
  58. else if (dwReason == DLL_PROCESS_DETACH)
  59. _Module.Term();
  60. return TRUE; // ok
  61. }
  62. /////////////////////////////////////////////////////////////////////////////
  63. // Used to determine whether the DLL can be unloaded by OLE
  64. STDAPI DllCanUnloadNow(void)
  65. {
  66. #ifdef _MERGE_PROXYSTUB
  67. if (PrxDllCanUnloadNow() != S_OK)
  68. return S_FALSE;
  69. #endif
  70. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  71. }
  72. /////////////////////////////////////////////////////////////////////////////
  73. // Returns a class factory to create an object of the requested type
  74. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  75. {
  76. #ifdef _MERGE_PROXYSTUB
  77. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  78. return S_OK;
  79. #endif
  80. return _Module.GetClassObject(rclsid, riid, ppv);
  81. }
  82. /////////////////////////////////////////////////////////////////////////////
  83. // DllRegisterServer - Adds entries to the system registry
  84. STDAPI DllRegisterServer(void)
  85. {
  86. REGISTER_SERVER_AND_CATID(CLSID_CWUpdInfo)
  87. }
  88. /////////////////////////////////////////////////////////////////////////////
  89. // DllUnregisterServer - Removes entries from the system registry
  90. STDAPI DllUnregisterServer(void)
  91. {
  92. UNREGISTER_SERVER_AND_CATID(CLSID_CWUpdInfo)
  93. }