# Function Reference

# _EventLog__Read

Reads an entry from the event log

#include <EventLog.au3>
_EventLog__Read ( $hEventLog [, $bRead = True [, $bForward = True [, $iOffset = 0]]] )

## Parameters

$hEventLog | A handle to the event log
$bRead | [optional] If True, operation proceeds sequentially from the last call to this function using this handle. If False, the read will operation proceeds from the record specified by the $iOffset parameter.
$bForward | [optional] If True, the log is read in date order. If False, the log is read in reverse date order.
$iOffset | [optional] The number of the event record at which the read operation should start. This parameter is ignored if $bRead is True.

## Return Value

Success: | an array with the following format: [ 0] - True [ 1] - Number of the record [ 2] - Date at which this entry was submitted [ 3] - Time at which this entry was submitted [ 4] - Date at which this entry was received to be written to the log [ 5] - Time at which this entry was received to be written to the log [ 6] - Event identifier [ 7] - Event type. This can be one of the following values: 1 - Error event 2 - Warning event 4 - Information event 8 - Success audit event 16 - Failure audit event [ 8] - Event type string [ 9] - Event category [10] - Event source [11] - Computer name [12] - Username [13] - Event description [14] - Event data array
Failure: | $Array[0] = False

## Remarks

When this function returns successfully, the read position in the event log is adjusted by the number of records read.
Though multiple records can be read, this function returns one record at a time for sanity sake.

## Related

_EventLog__Close, _EventLog__Open

## Example

    #include "Extras\HelpFileInternals.au3"

    #include <EventLog.au3>
    #include <FontConstants.au3>
    #include <GUIConstantsEx.au3>

    Example()

    Func Example()
        Local $hEventLog, $aEvent

        ; Create GUI
        GUICreate("EventLog", 600, 300)
        _MemoCreate(2, 2, 596, 294, 0)
        GUISetState(@SW_SHOW)

        ; Read most current event record
        $hEventLog = _EventLog__Open("", "Application")
        $aEvent = _EventLog__Read($hEventLog, True, False) ; read last event
        ; $hEventLog = _EventLog__Open("", "System")
        ; $aEvent = _EventLog__Read($hEventLog)
        ; $aEvent = _EventLog__Read($hEventLog, True, False)
        _MemoWrite("Result ............: " & $aEvent[0])
        _MemoWrite("Record number .....: " & $aEvent[1])
        _MemoWrite("Submitted .........: " & $aEvent[2] & " " & $aEvent[3])
        _MemoWrite("Generated .........: " & $aEvent[4] & " " & $aEvent[5])
        _MemoWrite("Event ID ..........: " & $aEvent[6])
        _MemoWrite("Type ..............: " & $aEvent[8])
        _MemoWrite("Category ..........: " & $aEvent[9])
        _MemoWrite("Source ............: " & $aEvent[10])
        _MemoWrite("Computer ..........: " & $aEvent[11])
        _MemoWrite("Username ..........: " & $aEvent[12])
        _MemoWrite("Description .......: " & $aEvent[13])
        _EventLog__Close($hEventLog)

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
    EndFunc   ;==>Example