#include <GUIConstantsEx.au3>
#include <StaticConstants.au3>
#include <WindowsConstants.au3>
#include <EventLog.au3>
#region
Global $hMainForm = GUICreate("日志", 801, 601, 192, 114)
Global $Group1 = GUICtrlCreateGroup("应用程序", 8, 8, 250, 580)
Global $gu_nEdit1 = GUICtrlCreateEdit("", 16, 32, 230, 550)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group2 = GUICtrlCreateGroup("安全性", 272, 8, 250, 580)
Global $gu_nEdit2 = GUICtrlCreateEdit("", 280, 32, 230, 550)
GUICtrlCreateGroup("", -99, -99, 1, 1)
Global $Group3 = GUICtrlCreateGroup("系统", 536, 8, 250, 580)
Global $gu_nEdit3 = GUICtrlCreateEdit("", 544, 32, 230, 550)
GUICtrlCreateGroup("", -99, -99, 1, 1)
#endregion
_Main()
Exit
Func _Main()
GUISetState(@SW_SHOW)
_EventReadApp()
_EventReadSec()
_EventReadSys()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case $GUI_EVENT_CLOSE
Exit
EndSwitch
WEnd
GUIDelete()
EndFunc
Func _EventReadApp()
_EventRead("", "Application", True, False, $gu_nEdit1)
EndFunc
Func _EventReadSec()
_EventRead("", "Security", True, False, $gu_nEdit2)
EndFunc
Func _EventReadSys()
_EventRead("", "System", True, False, $gu_nEdit3)
EndFunc
Func _EventRead($sServerName, $sSourceName, $fRead, $fForward, $nEdit)
Local $i
Local $hEventLog = _EventLog__Open($sServerName, $sSourceName)
Local $iCounts = _EventLog__Count($hEventLog)
For $i = 1 To $iCounts Step 1
$aEvent = _EventLog__Read($hEventLog, $fRead, $fForward, $i)
_EditWrite($nEdit, "结果 ............: " & $aEvent[0])
_EditWrite($nEdit, "记录数 .....: " & $aEvent[1])
_EditWrite($nEdit, "项目提交的日期 .........: " & $aEvent[2] & " " & $aEvent[3])
_EditWrite($nEdit, "项目被接收并被写入日志的日期 .........: " & $aEvent[4] & " " & $aEvent[5])
_EditWrite($nEdit, "事件标识 ..........: " & $aEvent[6])
_EditWrite($nEdit, "事件类型 ..............: " & $aEvent[7])
_EditWrite($nEdit, "事件类型字符串 ..............: " & $aEvent[8])
_EditWrite($nEdit, "事件科目 ..........: " & $aEvent[9])
_EditWrite($nEdit, "事件来源 ............: " & $aEvent[10])
_EditWrite($nEdit, "计算机名 ..........: " & $aEvent[11])
_EditWrite($nEdit, "用户名 ..........: " & $aEvent[12])
_EditWrite($nEdit, "事件描述 .......: " & $aEvent[13])
_EditWrite($nEdit, @CRLF)
Next
_EventLog__Close($hEventLog)
EndFunc
Func _EditWrite($nEdit, $sMessage)
GUICtrlSetData($nEdit, $sMessage & @CRLF, 1)
EndFunc