星期四, 九月 14, 2006

(VB.NET)读取日志记录

Imports System

Imports System.Management

Module Module1

Public Sub Main()

Dim strComputer = "magicdog"

Dim wbemServices, wbemObjectSet, wbemObject

wbemServices = GetObject("winmgmts:\\" & strComputer)

wbemObjectSet = wbemServices.InstancesOf("Win32_NTLogEvent")

For Each wbemObject In wbemObjectSet

Console.WriteLine("日志文件:" & wbemObject.LogFile)

Console.WriteLine("记录号:" & wbemObject.RecordNumber)

Console.WriteLine("类型:" & wbemObject.Type)

Console.WriteLine("产生时间:" & wbemObject.TimeGenerated)

Console.WriteLine("源名称:" & wbemObject.SourceName)

Console.WriteLine("事件代码:" & wbemObject.EventCode)

Console.WriteLine("用户" & wbemObject.User)

Console.WriteLine("计算机名:" & wbemObject.ComputerName)

Console.WriteLine("信息:" & wbemObject.Message)

Next

End Sub

End Module

没有评论: