RegisterEventSource

The RegisterEventSource function returns a registered handle to an event log.

HANDLE RegisterEventSource(
  LPCTSTR lpUNCServerName,  // server name for source
  LPCTSTR lpSourceName   // source name for registered handle
);
 

Parameters

lpUNCServerName
Pointer to a null-terminated string that specifies 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
Pointer to a null-terminated string that specifies the name of the source referenced by the returned handle. The source name must be a subkey of a logfile entry under the EventLog key in the registry. For example, WinApp is a valid source name if the registry has the following key:
HKEY_LOCAL_MACHINE 
  System 
    CurrentControlSet 
      Services 
        EventLog 
          Application 
            WinApp 
          Security 
          System 
 

Return Values

If the function succeeds, the return value is a handle that can be used with the ReportEvent function.

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

Remarks

If the source name cannot be found, the event logging service uses the Application logfile; 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, call the DeregisterEventSource function.

QuickInfo

  Windows NT: Requires version 3.1 or later.
  Windows: Unsupported.
  Windows CE: Unsupported.
  Header: Declared in winbase.h.
  Import Library: Use advapi32.lib.
  Unicode: Implemented as Unicode and ANSI versions on Windows NT.

See Also

Event Logging Overview, Event Logging Functions, DeregisterEventSource, ReportEvent