2 out of 4 rated this helpful - Rate this topic

OpenEventLog function

Applies to: desktop apps only

Opens a handle to the specified event log.

Syntax

HANDLE OpenEventLog(
  __in  LPCTSTR lpUNCServerName,
  __in  LPCTSTR lpSourceName
);

Parameters

lpUNCServerName [in]

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

lpSourceName [in]

The name of the log.

If you specify a custom log and it cannot be found, the event logging service opens the Application log; however, there will be no associated message or category string file.

Return value

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.

Examples

For an example, see Querying for Event Information.

Requirements

Minimum supported client

Windows 2000 Professional

Minimum supported server

Windows 2000 Server

Header

Winbase.h (include Windows.h)

Library

Advapi32.lib

DLL

Advapi32.dll

Unicode and ANSI names

OpenEventLogW (Unicode) and OpenEventLogA (ANSI)

See also

Eventlog Key
Event Logging Functions
ClearEventLog
CloseEventLog
ReadEventLog
ReportEvent

 

 

Send comments about this topic to Microsoft

Build date: 2/3/2012

Did you find this helpful?
(1500 characters remaining)
Community Content Add
Annotations FAQ
C# syntax
[DllImport("advapi32.dll", CharSet=CharSet.Unicode, SetLastError=true)]
public static extern SafeEventLogReadHandle OpenEventLog(string UNCServerName, string sourceName);
vb.net syntax
<DllImport("advapi32.dll", CharSet:=CharSet.Unicode, SetLastError:=True)> _
Public Shared Function OpenEventLog(ByVal UNCServerName As String, ByVal sourceName As String) As SafeEventLogReadHandle
End Function