Code:
'Read the event log dwRecordOffset = 1 pnMinNumberOfBytesNeeded = 50000& lResult = ReadEventLog(ByVal hEventLog, _ ByVal (%EVENTLOG_SEEK_READ Or %EVENTLOG_FORWARDS_READ), _ ByVal dwRecordOffset, _ ByVal VarPtr(eBuff(1)), _ pnMinNumberOfBytesNeeded, _ pnBytesRead, _ pnBytesNeeded) MoveMemory VarPtr(lpBuffer), VarPtr(eBuff(1)), Len(EVENTLOGRECORD) If IsFalse lResult Then MsgBox "Could not read event log",%MB_ICONSTOP,"EventLog" GoTo DONE End If 'MsgBox ReturnDate(lpBuffer.TimeGenerated) MsgBox "Source Name: " & lpBuffer.SourceName & $CRLF & "Computer Name: " & lpBuffer.ComputerName & $CRLF & "Strings: " & lpBuffer.Strings 'MsgBox "Length:" & Str$(EvtRecLen) & " pnBytesRead:" & Str$(pnBytesRead) & " pnMinNumberOfBytesNeeded:" & Str$(pnMinNumberOfBytesNeeded) & " Len(EVENTLOGRECORD):" & Str$(Len(EVENTLOGRECORD)) 'MsgBox "StringOffset:" & Str$(lpBuffer.StringOffset) & " NumStrings:" & Str$(lpBuffer.NumStrings) & " UserSidLength:" & Str$(lpBuffer.UserSidLength) For lLoop = lpBuffer.StringOffset To lpBuffer.Length ' print Source name and Computer name (may need more/fewer bytes printed) If( eBuff(lLoop) > 31 ) Then OutBuff = OutBuff & Chr$(eBuff(lLoop)) ElseIf eBuff(lLoop) = 0 Then OutBuff = OutBuff & $CRLF End If Next Function = OutBuff DONE: lResult = CloseEventLog(ByVal hEventLog)
Scott
Leave a comment: