OpenEventLog (advapi32)
Last changed: -42.99.164.65

.
Summary
Opens a handle to the specified event log.

C# Signature:

    [DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
    static extern IntPtr OpenEventLog(string UNCServerName, string sourceName);

VB Signature:

Declare Function OpenEventLog Lib "advapi32.dll" (TODO) As TODO

User-Defined Types:

None.

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

Use on Windows XP and Windows 2003 Only. For Windows Vista and above and with .NET 4, use EventLogSession class.

Tips & Tricks:

Please add some!

Sample Code:

IntPtr logHandle = OpenEventLog(Environment.MachineName, eventlogName);
if (IntPtr.Zero != logHandle)
{
    if (!BackupEventLog(logHandle, exportedEventLogFileName))
    {
     //Notify.
    }

    CloseEventLog(logHandle);
}
else
{
    int errorCode = Marshal.GetLastWin32Error();
    //Do something about it.
}

Documentation