# Function Reference

# _EventLog__Notify

Enables an application to receive event notifications

#include <EventLog.au3>
_EventLog__Notify ( $hEventLog, $hEvent )

## Parameters

$hEventLog | A handle to the event log
$hEvent | A handle to a manual-reset event object

## Return Value

Success: | True
Failure: | False

## Remarks

This function does not work with remote handles.
If the $hEventLog parameter is the handle to an event log on a remote computer, this function returns zero, and GetLastError returns ERROR_INVALID_HANDLE.
When an event is written to the log specified by $hEventLog, the system uses the PulseEvent function to set the event specified by the $hEvent parameter to the signaled state.
If the thread is not waiting on the event when the system calls PulseEvent, the thread will not receive the notification.
Therefore, you should create a separate thread to wait for notifications.
Note that the system calls PulseEvent no more than once every five seconds.
Therefore, even if more than one event log change occurs within a five second interval, you will only receive one notification.
The system will continue to notify you of changes until you close the handle to the event log.
To close the event log, use the _EventLog__Close() or _EventLog__DeregisterSource().

## Related

_EventLog__Close, _EventLog__DeregisterSource

## Example

    #include "Extras\HelpFileInternals.au3"

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

    Example()

    Func Example()
        Local $hEventLog, $hEvent, $iResult

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

        ; Set up event
        $hEventLog = _EventLog__Open("", "Security")
        $hEvent = _WinAPI_CreateEvent(0, False, False, "")
        _EventLog__Notify($hEventLog, $hEvent)

        ; Wait for new event to occur
        _MemoWrite("Waiting for new event")
        $iResult = _WinAPI_WaitForSingleObject($hEvent)
        _WinAPI_CloseHandle($hEvent)
        _EventLog__Close($hEventLog)

        ; Write results
        If $iResult = -1 Then
            _MemoWrite("Wait failed")
        Else
            _MemoWrite("New event occurred")
        EndIf

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