Click to Rate and Give Feedback
MSDN
MSDN Library
Diagnostics
Windows Events
Event Logging
 RegisterEventSource Function

  Switch on low bandwidth view
RegisterEventSource Function

Retrieves a registered handle to the specified event log.

Syntax

C++
HANDLE RegisterEventSource(
  __in  LPCTSTR lpUNCServerName,
  __in  LPCTSTR lpSourceName
);

Parameters

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.

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. 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.

Examples

For an example, see Reporting an Event.

Requirements

Minimum supported clientWindows 2000 Professional
Minimum supported serverWindows 2000 Server
HeaderWinbase.h (include Windows.h)
LibraryAdvapi32.lib
DLLAdvapi32.dll
Unicode and ANSI namesRegisterEventSourceW (Unicode) and RegisterEventSourceA (ANSI)

See Also

Event Logging Functions
Event Sources
DeregisterEventSource
ReportEvent

Send comments about this topic to Microsoft

Build date: 7/2/2009

Tags What's this?: Add a tag
Community Content   What is Community Content?
Add new content RSS  Annotations
vb.net syntax      dmex   |   Edit   |   Show History
<DllImport("advapi32.dll", CharSet:=CharSet.Unicode, SetLastError:=True)> _
Public Shared Function RegisterEventSource(ByVal uncServerName As String, ByVal sourceName As String) As SafeEventLogWriteHandle
End Function
Flag as ContentBug
C# syntax      dmex   |   Edit   |   Show History
[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
public static extern SafeEventLogWriteHandle RegisterEventSource(string uncServerName, string sourceName);
Tags What's this?: c# (x) syntax (x) Add a tag
Flag as ContentBug
Processing
© 2009 Microsoft Corporation. All rights reserved. Terms of Use  |  Trademarks  |  Privacy Statement
Page view tracker