Platform SDK: Debugging and Error Handling

OpenEventLog

The OpenEventLog function opens a handle to an event log.

HANDLE OpenEventLog(
  LPCTSTR lpUNCServerName,  // server name
  LPCTSTR lpSourceName      // file name
);

Parameters

lpUNCServerName
[in] Pointer to a null-terminated string that specifies the Universal Naming Convention (UNC) name of the server on which the event log is to be opened.
lpSourceName
[in] Pointer to a null-terminated string that specifies the name of the logfile that the returned handle will reference. This can be the Application, Security, or System logfile, or a custom registered logfile. If a custom registered logfile name cannot be found, the event logging service opens the Application logfile, however, there will be no associated message or category string file.

Return Values

If the function succeeds, the return value is the handle to an event log.

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

Remarks

To close the handle to the event log, use the CloseEventLog function.

Requirements

  Windows NT/2000: Requires Windows NT 3.1 or later.
  Windows 95/98: Unsupported.
  Header: Declared in Winbase.h; include Windows.h.
  Library: Use Advapi32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT/2000.

See Also

Event Logging Overview, Event Logging Functions, ClearEventLog, CloseEventLog, GetNumberOfEventLogRecords, GetOldestEventLogRecord, ReadEventLog, ReportEvent