Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

RegisterEventSource function

Retrieves a registered handle to the specified event log.


HANDLE RegisterEventSource(
  _In_ LPCTSTR lpUNCServerName,
  _In_ LPCTSTR lpSourceName


lpUNCServerName [in]

The Universal Naming Convention (UNC) name of the remote server on which this operation is to be performed. If this parameter is NULL, the local computer is used.

lpSourceName [in]

The name of the event source whose handle is to be retrieved. The source name must be a subkey of a log under the Eventlog registry key. Note that the Security log is for system use only.

Note  This string must not contain characters prohibited in XML Attributes, with the exception of XML Escape sequences such as &lt &gl.

Return value

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

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

The function returns ERROR_ACCESS_DENIED if lpSourceName specifies the Security event log.


If the source name cannot be found, the event logging service uses the Application log. Although events will be reported , the events will not include descriptions because there are no message and category message files for looking up descriptions related to the event identifiers.

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


For an example, see Reporting an Event.


Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]


Winbase.h (include Windows.h)





Unicode and ANSI names

RegisterEventSourceW (Unicode) and RegisterEventSourceA (ANSI)

See also

Event Logging Functions
Event Sources



Community Additions

© 2015 Microsoft