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.

127 lines
3.2 KiB

  1. /*++
  2. Copyright (C) 1996-2001 Microsoft Corporation
  3. Module Name:
  4. EVTLOG.H
  5. Abstract:
  6. Event Log helpers
  7. History:
  8. --*/
  9. #ifndef __WBEM_EVENT_LOG__H_
  10. #define __WBEM_EVENT_LOG__H_
  11. #define WBEM_EVENT_LOG_SOURCE L"WinMgmt"
  12. #define WBEM_EVENT_LOG_DUPLICATE_TIMEOUT 10
  13. #include "sync.h"
  14. class POLARITY CHex
  15. {
  16. protected:
  17. long m_l;
  18. public:
  19. CHex(long l) : m_l(l){}
  20. operator long() {return m_l;}
  21. };
  22. class POLARITY CInsertionString
  23. {
  24. protected:
  25. BOOL m_bEmpty;
  26. WString m_ws;
  27. public:
  28. CInsertionString() : m_bEmpty(TRUE){}
  29. CInsertionString(LPCWSTR wsz) : m_bEmpty(FALSE), m_ws(wsz){}
  30. CInsertionString(LPCSTR sz) : m_bEmpty(FALSE), m_ws(sz){}
  31. CInsertionString(long l);
  32. CInsertionString(CHex h);
  33. LPCWSTR GetString() {return m_ws;}
  34. BOOL IsEmpty() {return m_bEmpty;}
  35. };
  36. class POLARITY CEventLogRecord
  37. {
  38. protected:
  39. WORD m_wType;
  40. DWORD m_dwEventID;
  41. CWStringArray m_awsStrings;
  42. CWbemTime m_CreationTime;
  43. protected:
  44. void AddInsertionString(CInsertionString& s);
  45. public:
  46. CEventLogRecord(WORD wType, DWORD dwEventID,
  47. CInsertionString s1 = CInsertionString(),
  48. CInsertionString s2 = CInsertionString(),
  49. CInsertionString s3 = CInsertionString(),
  50. CInsertionString s4 = CInsertionString(),
  51. CInsertionString s5 = CInsertionString(),
  52. CInsertionString s6 = CInsertionString(),
  53. CInsertionString s7 = CInsertionString(),
  54. CInsertionString s8 = CInsertionString(),
  55. CInsertionString s9 = CInsertionString(),
  56. CInsertionString s10 = CInsertionString());
  57. ~CEventLogRecord(){}
  58. WORD GetNumStrings() {return (WORD) m_awsStrings.Size();}
  59. LPCWSTR GetStringAt(int nIndex);
  60. CWbemTime GetCreationTime() {return m_CreationTime;}
  61. BOOL operator==(const CEventLogRecord& Other);
  62. };
  63. POLARITY typedef CUniquePointerArray<CEventLogRecord> LogRecords;
  64. class POLARITY CEventLog
  65. {
  66. private:
  67. WString m_wsServerName;
  68. WString m_wsSourceName;
  69. HANDLE m_hSource;
  70. FILE* m_fLog;
  71. BOOL m_bNT;
  72. DWORD m_dwTimeout;
  73. LogRecords* m_pRecords;
  74. CCritSec m_cs;
  75. protected:
  76. BOOL SearchForRecord(CEventLogRecord* pRecord);
  77. void AddRecord(CEventLogRecord* pRecord);
  78. public:
  79. CEventLog(LPCWSTR wszUNCServerName = NULL,
  80. LPCWSTR wszSourceName = WBEM_EVENT_LOG_SOURCE,
  81. DWORD dwTimeout = WBEM_EVENT_LOG_DUPLICATE_TIMEOUT);
  82. ~CEventLog();
  83. BOOL Close();
  84. BOOL Open();
  85. BOOL Report(WORD wType, DWORD dwEventID,
  86. CInsertionString s1 = CInsertionString(),
  87. CInsertionString s2 = CInsertionString(),
  88. CInsertionString s3 = CInsertionString(),
  89. CInsertionString s4 = CInsertionString(),
  90. CInsertionString s5 = CInsertionString(),
  91. CInsertionString s6 = CInsertionString(),
  92. CInsertionString s7 = CInsertionString(),
  93. CInsertionString s8 = CInsertionString(),
  94. CInsertionString s9 = CInsertionString(),
  95. CInsertionString s10 = CInsertionString());
  96. };
  97. #endif