EntryWrittenEventArgs.Entry 属性

定义

获取写入到日志中的事件日志项。

public:
 property System::Diagnostics::EventLogEntry ^ Entry { System::Diagnostics::EventLogEntry ^ get(); };
public System.Diagnostics.EventLogEntry Entry { get; }
member this.Entry : System.Diagnostics.EventLogEntry
Public ReadOnly Property Entry As EventLogEntry

属性值

一个 EventLogEntry,它表示写入到事件日志中的项。

示例

以下示例假定已在 中 EntryWrittenEventArgs(EventLogEntry)实现了 示例。

它创建自定义 EventLog 对象,并在其中写入一个条目。 然后,它使用自定义 EventLog 中的第一个 EntryWrittenEventArgs 条目创建对象。 此对象用于通知消息。

void MyOnEntry( Object^ source, EntryWrittenEventArgs^ e )
{
   EventLogEntry^ myEventLogEntry = e->Entry;
   if ( myEventLogEntry )
   {
      Console::WriteLine( "Current message entry is: '{0}'", myEventLogEntry->Message );
   }
   else
   {
      Console::WriteLine( "The current entry is null" );
   }
}
protected static void MyOnEntry(Object source, EntryWrittenEventArgs e)
{
    EventLogEntry myEventLogEntry = e.Entry;
    if (myEventLogEntry != null)
    {
        Console.WriteLine("Current message entry is: '"
                          + myEventLogEntry.Message + "'");
    }
    else
    {
        Console.WriteLine("The current entry is null");
    }
}
Protected Shared Sub MyOnEntry(source As Object, e As EntryWrittenEventArgs)
   Dim myEventLogEntry As EventLogEntry = e.Entry
   If Not (myEventLogEntry Is Nothing) Then
      Console.WriteLine("Current message entry is: '" + _
                                          myEventLogEntry.Message + "'")
   Else
      Console.WriteLine("The current entry is null")
   End If
End Sub

适用于