Retrieves a registered handle to the specified event log.
Syntax
HANDLE RegisterEventSource(
__in LPCTSTR lpUNCServerName,
__in LPCTSTR lpSourceName
);
Parameters
- lpUNCServerName
-
The Universal Naming Convention (UNC) name of the server on which this operation is to be performed. If this parameter is NULL, the operation is performed on the local computer.
- lpSourceName
-
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.
However, the Security log is for system use only.
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_INVALID_HANDLE if lpSourceName specifies the Security event log.
Remarks
If the source name cannot be found, the event logging service uses the Application log; it does not create a new source. Events are reported for the source, however, there are no message and category message files specified for looking up descriptions of the event identifiers for the source.
To close the handle to the event log, use the
DeregisterEventSource function.
Example Code
For an example, see
Reporting an Event.
Requirements
| Client | Requires Windows Vista, Windows XP, Windows 2000 Professional, or Windows NT Workstation. |
| Server | Requires Windows Server 2008, Windows Server 2003, Windows 2000 Server, or Windows NT Server. |
| Header | Declared in Winbase.h; include Windows.h. |
| Library | Use Advapi32.lib. |
| DLL | Requires Advapi32.dll. |
| Unicode | Implemented as RegisterEventSourceW (Unicode) and RegisterEventSourceA (ANSI). |
See Also
Event Logging Functions
Event Sources
DeregisterEventSource
ReportEvent
Send comments about this topic to Microsoft
Build date: 2/28/2008