Platform SDK: Debugging and Error Handling

NotifyChangeEventLog

The NotifyChangeEventLog function enables an application to receive notification when an event is written to the specified event logfile. When the event is written to the event logfile, the specified event object is set to the signaled state.

BOOL NotifyChangeEventLog(
  HANDLE hEventLog,  // handle to event log
  HANDLE hEvent      // handle to event object
);

Parameters

hEventLog
[in] Handle to an event logfile. This handle is returned by the OpenEventLog or OpenBackupEventLog function.
hEvent
[in] Handle to a manual-reset event object. Use the CreateEvent function to create the event object.

Return Values

If the function succeeds, the return value is nonzero.

If the function fails, the return value is zero. To get extended error information, call GetLastError.

Remarks

The NotifyChangeEventLog function does not work with remote handles. If the hEventLog parameter is the handle to an event log on a remote computer, NotifiyChangeEventLog returns zero, and GetLastError returns ERROR_INVALID_HANDLE.

When an event is written to the logfile 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 CloseEventLog or DeregisterEventSource function.

Requirements

  Windows NT/2000: Requires Windows NT 3.5 or later.
  Windows 95/98: Unsupported.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Advapi32.lib.

See Also

Event Logging Overview, Event Logging Functions, CloseEventLog, CreateEvent, DeregisterEventSource, OpenBackupEventLog, OpenEventLog