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.

91 lines
2.8 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // Copyright: Microsoft Corp. 1997-1999. All rights reserved
  4. //
  5. /////////////////////////////////////////////////////////////////////////////
  6. // Event.h : Declaration of the CEvent
  7. #ifndef __EVENT_H_
  8. #define __EVENT_H_
  9. #include "resource.h" // main symbols
  10. /////////////////////////////////////////////////////////////////////////////
  11. // CEvent
  12. class ATL_NO_VTABLE CEvent :
  13. public CComObjectRootEx<CComSingleThreadModel>,
  14. public CComCoClass<CEvent, &CLSID_Event>,
  15. public ISupportErrorInfo,
  16. public IDispatchImpl<IEvent, &IID_IEvent, &LIBID_EventLogUtilities>
  17. {
  18. private:
  19. long m_EventID; // Note: EventID is displayed as WORD instead of DWORD in the System's EventViewer
  20. long m_EventCategory; // origionally a WORD (unsigned short)
  21. eEventType m_EventType;
  22. _bstr_t m_Description;
  23. _bstr_t m_SourceName;
  24. _bstr_t m_EventLogName;
  25. _bstr_t m_ComputerName;
  26. _bstr_t m_UserName;
  27. DATE m_OccurrenceTime;
  28. BYTE* m_pSid;
  29. SAFEARRAY* m_pDataArray;
  30. wchar_t** m_ppArgList;
  31. unsigned int m_NumberOfStrings;
  32. // Internal only functions
  33. HRESULT CheckDefaultDescription(wchar_t** Arguments);
  34. HRESULT ParseEventBlob(EVENTLOGRECORD* pEventStructure);
  35. HRESULT SetUser();
  36. public:
  37. CEvent() : m_EventID(0), m_EventCategory(0), m_OccurrenceTime(0), m_pSid(NULL), m_pDataArray(NULL), m_NumberOfStrings(0), m_ppArgList(NULL)
  38. {
  39. m_Description = "";
  40. m_SourceName = "";
  41. m_ComputerName = "";
  42. m_UserName = "";
  43. m_EventLogName = "";
  44. }
  45. ~CEvent()
  46. {
  47. unsigned int i;
  48. if (m_pSid) delete []m_pSid;
  49. if (m_ppArgList)
  50. {
  51. for (i=0;i<m_NumberOfStrings;i++)
  52. delete [] m_ppArgList[i];
  53. delete []m_ppArgList;
  54. }
  55. // if (m_pDataArray) SafeArrayDestroy(m_pDataArray); // causes access violation
  56. }
  57. // Internal functions
  58. HRESULT Init(EVENTLOGRECORD* pEventStructure, const LPCTSTR szEventLogName);
  59. DECLARE_REGISTRY_RESOURCEID(IDR_EVENT)
  60. DECLARE_PROTECT_FINAL_CONSTRUCT()
  61. BEGIN_COM_MAP(CEvent)
  62. COM_INTERFACE_ENTRY(IEvent)
  63. COM_INTERFACE_ENTRY(IDispatch)
  64. COM_INTERFACE_ENTRY(ISupportErrorInfo)
  65. END_COM_MAP()
  66. // ISupportsErrorInfo
  67. STDMETHOD(InterfaceSupportsErrorInfo)(REFIID riid);
  68. // IEvent
  69. STDMETHOD(get_EventID)(/*[out, retval]*/ long *pVal);
  70. STDMETHOD(get_EventType)(/*[out, retval]*/ eEventType *pVal);
  71. STDMETHOD(get_Category)(/*[out, retval]*/ long *pVal);
  72. STDMETHOD(get_Description)(/*[out, retval]*/ BSTR *pVal);
  73. STDMETHOD(get_Source)(/*[out, retval]*/ BSTR *pVal);
  74. STDMETHOD(get_User)(/*[out, retval]*/ BSTR *pVal);
  75. STDMETHOD(get_OccurrenceTime)(/*[out, retval]*/ DATE *pVal);
  76. STDMETHOD(get_ComputerName)(/*[out, retval]*/ BSTR *pVal);
  77. STDMETHOD(get_Data)(/*[out, retval]*/ VARIANT *pVal);
  78. };
  79. #endif //__EVENT_H_