[DllImport("advapi32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
static extern IntPtr OpenEventLog(string UNCServerName, string sourceName);
Declare Function OpenEventLog Lib "advapi32.dll" (TODO) As TODO
None.
Do you know one? Please contribute it!
Use on Windows XP and Windows 2003 Only. For Windows Vista and above and with .NET 4, use EventLogSession class.
Please add some!
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.
}