如果要读取日志信息,参考代码
'Windows日志有:"Application"应用程序, "Security"安全, "System"系统
Dim logs As String() = New String() {"Application", "System"}
For Each log As String In logs
Dim myLog As New System.Diagnostics.EventLog()
myLog.Log = log
For Each entry As System.Diagnostics.EventLogEntry In myLog.Entries
'EventLogEntryType枚举包括:
'Error 错误事件.
'FailureAudit 失败审核事件.
'Information 信息事件.
'SuccessAudit 成功审核事件.
'Warning 警告事件.
If entry.EntryType = System.Diagnostics.EventLogEntryType.[Error] OrElse entry.EntryType = System.Diagnostics.EventLogEntryType.Warning Then
Dim result As New StringBuilder()
result.Append(log & " ")
result.Append(entry.EntryType.ToString() & " ")
result.Append(entry.TimeWritten.ToString() & " ")
result.Append(entry.Message & vbcrlf)
output.show(result.Tostring)
End If
Next
Next