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.

135 lines
3.4 KiB

  1. //+---------------------------------------------------------------------------
  2. //
  3. // Copyright (C) 1998 Microsoft Corporation. All rights reserved.
  4. //
  5. // init.cpp : Implementation of DLL Exports.
  6. // Note: Proxy/Stub Information
  7. // To merge the proxy/stub code into the object DLL, add the file
  8. // dlldatax.c to the project. Make sure precompiled headers
  9. // are turned off for this file, and add _MERGE_PROXYSTUB to the
  10. // defines for the project.
  11. //
  12. // If you are not running WinNT4.0 or Win95 with DCOM, then you
  13. // need to remove the following define from dlldatax.c
  14. // #define _WIN32_WINNT 0x0400
  15. //
  16. // Further, if you are running MIDL without /Oicf switch, you also
  17. // need to remove the following define from dlldatax.c.
  18. // #define USE_STUBLESS_PROXY
  19. //
  20. // Modify the custom build rule for AUO.idl by adding the following
  21. // files to the Outputs.
  22. // AUO_p.c
  23. // dlldata.c
  24. // To build a separate proxy/stub DLL,
  25. // run nmake -f AUOps.mk in the project directory.
  26. #include "precomp.h"
  27. #include "initguid.h"
  28. #include "ulperf.h"
  29. #ifdef _MERGE_PROXYSTUB
  30. extern "C" HINSTANCE hProxyDll;
  31. #endif
  32. CComModule _Module;
  33. GUID LIBID_StdOle2 = {0x00020430,0x0000,0x0000,{0xC0,0x00,0x00,0x00,0x00,0x00,0x00,0x46}};
  34. BEGIN_OBJECT_MAP(ObjectMap)
  35. OBJECT_ENTRY(CLSID_UlPerfCounters, CUlPerfCounters)
  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. _Module.Init(ObjectMap, hInstance);
  50. g_hInstance = hInstance;
  51. DisableThreadLibraryCalls(hInstance);
  52. g_lInit = 0;
  53. }
  54. else if (dwReason == DLL_PROCESS_DETACH)
  55. {
  56. _Module.Term();
  57. }
  58. return TRUE; // ok
  59. }
  60. /////////////////////////////////////////////////////////////////////////////
  61. // Used to determine whether the DLL can be unloaded by OLE
  62. STDAPI DllCanUnloadNow(void)
  63. {
  64. // AFX_MANAGE_STATE(AfxGetStaticModuleState());
  65. #ifdef _MERGE_PROXYSTUB
  66. if (PrxDllCanUnloadNow() != S_OK)
  67. return S_FALSE;
  68. #endif
  69. return S_FALSE;
  70. // return (AfxDllCanUnloadNow()==S_OK && _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. // AFX_MANAGE_STATE(AfxGetStaticModuleState());
  77. #ifdef _MERGE_PROXYSTUB
  78. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  79. return S_OK;
  80. #endif
  81. return _Module.GetClassObject(rclsid, riid, ppv);
  82. }
  83. /////////////////////////////////////////////////////////////////////////////
  84. // DllRegisterServer - Adds entries to the system registry
  85. STDAPI DllRegisterServer(void)
  86. {
  87. // AFX_MANAGE_STATE(AfxGetStaticModuleState());
  88. #ifdef _MERGE_PROXYSTUB
  89. HRESULT hRes = PrxDllRegisterServer();
  90. if (FAILED(hRes))
  91. return hRes;
  92. #endif
  93. // registers object, typelib and all interfaces in typelib
  94. return _Module.RegisterServer();
  95. }
  96. /////////////////////////////////////////////////////////////////////////////
  97. // DllUnregisterServer - Removes entries from the system registry
  98. STDAPI DllUnregisterServer(void)
  99. {
  100. // AFX_MANAGE_STATE(AfxGetStaticModuleState());
  101. #ifdef _MERGE_PROXYSTUB
  102. PrxDllUnregisterServer();
  103. #endif
  104. _Module.UnregisterServer();
  105. return S_OK;
  106. }