Функция _EventLog__Notify

         Описание функции


_EventLog__Notify

Enables an application to receive event notifications

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

Параметры

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

Возвращаемое значение

Успех:Возвращает True
Ошибка:Возвращает False

Примечания

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 function.

См. также

_EventLog__Close, _EventLog__DeregisterSource

Пример

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

Global $iMemo

_Main()

Func _Main()
    Local $hEventLog, $hGUI, $hEvent, $iResult

    ; Создаёт GUI
    $hGUI = GUICreate("EventLog", 400, 300)
    $iMemo = GUICtrlCreateEdit("", 2, 2, 396, 300, 0)
    GUICtrlSetFont($iMemo, 9, 400, 0, "Courier New")
    GUISetState()

    ; 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

    ; Цикл выполняется, пока окно не будет закрыто
    Do
    Until GUIGetMsg() = $GUI_EVENT_CLOSE

EndFunc   ;==>_Main

; Записывает строку в элемент для заметок
Func MemoWrite($sMessage)
    GUICtrlSetData($iMemo, $sMessage & @CRLF, 1)
EndFunc   ;==>MemoWrite