• XbReadEventLog(nEvtHandle, nReadFlag [, nOffset])


    • Description
      This function is used to read a whole number of entries from the specified event log.
      The function can be used to read log entries in forward or reverse chronological order.

    • Parameter(s)

      nEvtHandle
      Identifies the event log whose handle was returned by XbRegEventSource.

      nReadFlag
      Specifies the type for read-order
      This parameter can be one of the following values:

      Value   Meaning
      EVENTLOG_FORWARDS_READ The log is read in forward chronological order.
      EVENTLOG_BACKWARDS_READ The log is read in reverse chrono-
      logical order.
      EVENTLOG_SEEK_READ The read operation proceeds from the record specified by the nOffset parameter. If this flag is used, nReadFlags must also specify EVENTLOG_FORWARDS_READ or EVENTLOG_BACKWARDS_READ.  the additional flag indicates the direction for successive read operations.
      EVENTLOG_SEQUENTIAL_READ The read operation proceeds sequentially from the last call to the XbReadEventLog function using this handle.


      nOffset
      Specifies the log-entry record number at which the read operation should start.
      This parameter is ignored unless the nReadFlags parameter includes the EVENTLOG_SEEK_READ flag.

    • Return Value
      If the function succeeds, the return value is an Array.
      The minimum length of this Array is 7 elements:

      Element Type Description
      1    Numeric Contains a record number that can be used with the
      EVENTLOG_SEEK_READ flag passed in a call to the ReadEventLog
      function to begin reading at a specified record.
      2 Numeric The time at which this entry was submitted. This time is measured in the
      number of seconds elapsed since 00:00:00 January 1, 1970.
      (use XbFormatDateTime to convert)
      3 Numeric Specifies the time at which this entry was received by the service to be
      written to the logfile. This time is measured in the number of seconds
      elapsed since 00:00:00 January 1, 1970.
      (use XbFormatDateTime to convert)
      4 Numeric Identifies the event. This is specific to the source that generated the event
      log entry, and is used, together with SourceName, to identify a message in a message file that is presented to the user while viewing the log.
      5 Numeric Specifies the type of event. This member can be one of the following values:
      Value   Meaning
      EVENTLOG_ERROR_TYPE Error event
      EVENTLOG_WARNING_TYPE Warning event
      EVENTLOG_INFORMATION_TYPE Information event
      EVENTLOG_AUDIT_SUCCESS Success Audit event
      EVENTLOG_AUDIT_FAILURE Failure Audit event
      6 Numeric Specifies the number of strings present in the log
      7 Numeric Specifies a subcategory for this event. This subcategory is source specific.
      8 to ... Character strings of this event log entry.


      Otherwise this function returns an errorcode.
      To get extended error information, call XbEventGetLastError.

  • Sample
    #include "xbevent.ch"

    local nEvtHandle:= 0
    local cError    := space(100)
    local aEventArray
    local nFlag     := EVENTLOG_SEEK_READ+EVENTLOG_FORWARDS_READ

    //
    // open a Eventlog-Key
    //
    if ((nEvtHandle := XbOpenEventLog(, "WinApp")) <= 0)
      XbEventGetLastError(@cError)
      ? "Error :", cError
    else
      //
      // we will read the first entry
      //
      aEventArray := XbReadEventLog(nEvtHandle, nFlag, 1)
      if (ValType(aEventArray) == "A")
        ? aEventString[8]
      endif

      XbCloseEventLog(nEvtHandle)
    endif