Leaked source code of windows server 2003
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.

128 lines
3.8 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright: Microsoft Corp. 1997-1999. All rights reserved
  4. //
  5. /////////////////////////////////////////////////////////////////////////////
  6. // EventLogUtilities.cpp : Implementation of DLL Exports.
  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 EventLogUtilities.idl by adding the following
  22. // files to the Outputs.
  23. // EventLogUtilities_p.c
  24. // dlldata.c
  25. // To build a separate proxy/stub DLL,
  26. // run nmake -f EventLogUtilitiesps.mk in the project directory.
  27. #include "stdafx.h"
  28. #include "resource.h"
  29. #include <initguid.h>
  30. #include "Evntutl.h"
  31. #include "dlldatax.h"
  32. #include "EvntUtl_i.c"
  33. #include "View.h"
  34. // #include "Logs.h"
  35. #include "Log.h"
  36. // #include "Events.h"
  37. #include "Event.h"
  38. #ifdef _MERGE_PROXYSTUB
  39. extern "C" HINSTANCE hProxyDll;
  40. #endif
  41. CComModule _Module;
  42. BEGIN_OBJECT_MAP(ObjectMap)
  43. OBJECT_ENTRY(CLSID_View, CView)
  44. // OBJECT_ENTRY(CLSID_Logs, CLogs)
  45. OBJECT_ENTRY(CLSID_Log, CLog)
  46. // OBJECT_ENTRY(CLSID_Events, CEvents)
  47. OBJECT_ENTRY(CLSID_Event, CEvent)
  48. END_OBJECT_MAP()
  49. /////////////////////////////////////////////////////////////////////////////
  50. // DLL Entry Point
  51. extern "C"
  52. BOOL WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID lpReserved)
  53. {
  54. lpReserved;
  55. #ifdef _MERGE_PROXYSTUB
  56. if (!PrxDllMain(hInstance, dwReason, lpReserved))
  57. return FALSE;
  58. #endif
  59. if (dwReason == DLL_PROCESS_ATTACH)
  60. {
  61. _Module.Init(ObjectMap, hInstance, &LIBID_EventLogUtilities);
  62. DisableThreadLibraryCalls(hInstance);
  63. }
  64. else if (dwReason == DLL_PROCESS_DETACH)
  65. _Module.Term();
  66. return TRUE; // ok
  67. }
  68. /////////////////////////////////////////////////////////////////////////////
  69. // Used to determine whether the DLL can be unloaded by OLE
  70. STDAPI DllCanUnloadNow(void)
  71. {
  72. #ifdef _MERGE_PROXYSTUB
  73. if (PrxDllCanUnloadNow() != S_OK)
  74. return S_FALSE;
  75. #endif
  76. return (_Module.GetLockCount()==0) ? S_OK : S_FALSE;
  77. }
  78. /////////////////////////////////////////////////////////////////////////////
  79. // Returns a class factory to create an object of the requested type
  80. STDAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID* ppv)
  81. {
  82. #ifdef _MERGE_PROXYSTUB
  83. if (PrxDllGetClassObject(rclsid, riid, ppv) == S_OK)
  84. return S_OK;
  85. #endif
  86. return _Module.GetClassObject(rclsid, riid, ppv);
  87. }
  88. /////////////////////////////////////////////////////////////////////////////
  89. // DllRegisterServer - Adds entries to the system registry
  90. STDAPI DllRegisterServer(void)
  91. {
  92. MessageBox(NULL, TEXT("Registering eventutl.dll"), TEXT("evntutl.dll"), MB_OK);
  93. #ifdef _MERGE_PROXYSTUB
  94. HRESULT hRes = PrxDllRegisterServer();
  95. if (FAILED(hRes))
  96. return hRes;
  97. #endif
  98. // registers object, typelib and all interfaces in typelib
  99. return _Module.RegisterServer(TRUE);
  100. }
  101. /////////////////////////////////////////////////////////////////////////////
  102. // DllUnregisterServer - Removes entries from the system registry
  103. STDAPI DllUnregisterServer(void)
  104. {
  105. #ifdef _MERGE_PROXYSTUB
  106. PrxDllUnregisterServer();
  107. #endif
  108. return _Module.UnregisterServer(TRUE);
  109. }