EntryWrittenEventArgs コンストラクタとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > EntryWrittenEventArgs コンストラクタの意味・解説 

EntryWrittenEventArgs コンストラクタ (EventLogEntry)

指定したイベント ログ エントリを使用して、EntryWrittenEventArgs クラス新しインスタンス初期化します。

名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)
構文構文

Public Sub New ( _
    entry As EventLogEntry _
)
Dim entry As EventLogEntry

Dim instance As New EntryWrittenEventArgs(entry)
public EntryWrittenEventArgs (
    EventLogEntry entry
)
public:
EntryWrittenEventArgs (
    EventLogEntry^ entry
)
public EntryWrittenEventArgs (
    EventLogEntry entry
)
public function EntryWrittenEventArgs (
    entry : EventLogEntry
)

パラメータ

entry

書き込まれたエントリを表す EventLogEntry。

使用例使用例

EntryWrittenEventArgs コンストラクタの例を次に示します。これは、カスタム EventLog オブジェクト作成して、エントリを書き込みます次にカスタム EventLog 内の最初のエントリを使用して EntryWrittenEventArgs オブジェクト作成します。このオブジェクトは、メッセージ通知するときに使用します

Imports System
Imports System.Diagnostics

Class MySample
   Public Shared Sub Main()
      Try
         Dim myNewLog As New
 EventLog()
         ' Create the source if it does not exist already.
         If Not EventLog.SourceExists("MySource")
 Then
            EventLog.CreateEventSource("MySource",
 "MyNewLog")
            Console.WriteLine("CreatingEventSource")
         End If
         myNewLog.Log = "MyNewLog"
         myNewLog.Source = "MySource"
         ' Write an entry to the EventLog.
         myNewLog.WriteEntry("The Latest entry in the Event Log")

         Dim myEntries As Integer
 = myNewLog.Entries.Count
         Dim entry As EventLogEntry = myNewLog.Entries(myEntries
 - 1)
         Dim myEntryEventArgs As New
 EntryWrittenEventArgs(entry)
         MyOnEntry(myNewLog, myEntryEventArgs)
      Catch e As Exception
         Console.WriteLine("Exception Raised" + e.Message)
      End Try
   End Sub 'Main

   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 'MyOnEntry
End Class 'MySample
using System;
using System.Diagnostics;

   class MySample
   {
      public static void
 Main()
      {
         try
         {
            EventLog myNewLog = new EventLog();
            myNewLog.Log = "MyNewLog";
            myNewLog.Source="MySource";
            // Create the source if it does not exist already.
            if(!EventLog.SourceExists("MySource"))
            {
               EventLog.CreateEventSource("MySource", "MyNewLog");
               Console.WriteLine("CreatingEventSource");
            }
            // Write an entry to the EventLog.
            myNewLog.WriteEntry("The Latest entry in the
 Event Log");
            int myEntries = myNewLog.Entries.Count;
            EventLogEntry entry =myNewLog.Entries[myEntries-1];
            EntryWrittenEventArgs myEntryEventArgs=
                                 new EntryWrittenEventArgs(entry);
            MyOnEntry(myNewLog,myEntryEventArgs);
         }
         catch(Exception e)
         {
            Console.WriteLine("Exception Raised" +e.Message);
         }
      }
      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");
         }
      }
   }
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;

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"
 );
   }
}

int main()
{
   try
   {
      EventLog^ myNewLog = gcnew EventLog;
      myNewLog->Log = "MyNewLog";
      myNewLog->Source = "MySource";
      
      // Create the source if it does not exist already.
      if (  !EventLog::SourceExists( "MySource" ) )
      {
         EventLog::CreateEventSource( "MySource", "MyNewLog"
 );
         Console::WriteLine( "CreatingEventSource" );
      }
      
      // Write an entry to the EventLog.
      myNewLog->WriteEntry( "The Latest entry in the Event
 Log" );
      int myEntries = myNewLog->Entries->Count;
      EventLogEntry^ entry = myNewLog->Entries[ myEntries - 1 ];
      EntryWrittenEventArgs^ myEntryEventArgs = gcnew EntryWrittenEventArgs( entry
 );
      MyOnEntry( myNewLog, myEntryEventArgs );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception Raised {0}", e->Message );
   }
}
import System.*;
import System.Diagnostics.*;

class MySample
{
    public static void main(String[]
 args)
    {
        try {
            EventLog myNewLog = new EventLog();
            myNewLog.set_Log("MyNewLog");
            myNewLog.set_Source("MySource");

            // Create the source if it does not exist already.
            if (!(EventLog.SourceExists("MySource")))
 {
                EventLog.CreateEventSource("MySource", "MyNewLog");
                Console.WriteLine("CreatingEventSource");
            }
            // Write an entry to the EventLog.
            myNewLog.WriteEntry("The Latest entry in the
 Event Log");
            int myEntries = myNewLog.get_Entries().get_Count();
            EventLogEntry entry = 
                myNewLog.get_Entries().get_Item((myEntries - 1));
            EntryWrittenEventArgs myEntryEventArgs = 
                new EntryWrittenEventArgs(entry);
            MyOnEntry(myNewLog, myEntryEventArgs);
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception Raised" + e.get_Message());
        }
    } //main

    protected static void
 MyOnEntry(Object source, EntryWrittenEventArgs e)
    {
        EventLogEntry myEventLogEntry = e.get_Entry();
        if (myEventLogEntry != null) {
            Console.WriteLine("Current message entry is: '" 
                + myEventLogEntry.get_Message() + "'");
        }
        else {
            Console.WriteLine("The current entry is null");
        }
    } //MyOnEntry
} //MySample 
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EntryWrittenEventArgs クラス
EntryWrittenEventArgs メンバ
System.Diagnostics 名前空間

EntryWrittenEventArgs コンストラクタ

EntryWrittenEventArgs クラス新しインスタンス初期化します。
オーバーロードの一覧オーバーロードの一覧

名前 説明
EntryWrittenEventArgs () EntryWrittenEventArgs クラス新しインスタンス初期化します。
EntryWrittenEventArgs (EventLogEntry) 指定したイベント ログ エントリを使用してEntryWrittenEventArgs クラス新しインスタンス初期化します。
参照参照

関連項目

EntryWrittenEventArgs クラス
EntryWrittenEventArgs メンバ
System.Diagnostics 名前空間

EntryWrittenEventArgs コンストラクタ ()

EntryWrittenEventArgs クラス新しインスタンス初期化します。

名前空間: System.Diagnostics
アセンブリ: System (system.dll 内)
構文構文

Dim instance As New EntryWrittenEventArgs
public EntryWrittenEventArgs ()
public:
EntryWrittenEventArgs ()
public EntryWrittenEventArgs ()
public function EntryWrittenEventArgs ()
使用例使用例

EntryWrittenEventArgs コンストラクタの例を次に示します。これは、カスタム EventLog オブジェクト作成して、エントリを書き込みます次にカスタム EventLog 内の最初のエントリを使用して EntryWrittenEventArgs オブジェクト作成します。このオブジェクトは、メッセージ通知するときに使用します

Imports System
Imports System.Diagnostics

Class MySample
   Public Shared Sub Main()
      Try
         Dim myNewLog As New
 EventLog()
         myNewLog.Log = "MyNewLog"
         myNewLog.Source = "MySource"
         ' Create the source if it does not exist already.
         If Not EventLog.SourceExists("MySource")
 Then
            EventLog.CreateEventSource("MySource",
 "MyNewLog")
            Console.WriteLine("CreatingEventSource")
         End If
         ' Write an entry to the EventLog.
         myNewLog.WriteEntry("The Latest entry in the Event Log")
         Dim myEntryEventArgs As EntryWrittenEventArgs
 = _
                                    New EntryWrittenEventArgs()
         MyOnEntry(myNewLog, myEntryEventArgs)
      Catch e As Exception
         Console.WriteLine("Exception Raised" + e.Message)
      End Try
   End Sub 'Main
   Protected Shared Sub
 MyOnEntry(ByVal source As Object,
 _
                                  ByVal e As
 EntryWrittenEventArgs)
      If e.Entry Is Nothing
 Then
          Console.WriteLine("A new entry is written in MyNewLog.")
      End If
   End Sub 'MyOnEntry
End Class 'MySample
using System;
using System.Diagnostics;

   class MySample
   {
      public static void
 Main()
      {
         try
         {
            EventLog myNewLog = new EventLog();
            myNewLog.Log = "MyNewLog";
            myNewLog.Source="MySource";
            // Create the source if it does not exist already.
            if(!EventLog.SourceExists("MySource"))
            {
               EventLog.CreateEventSource("MySource", "MyNewLog");
               Console.WriteLine("CreatingEventSource");
            }
               // Write an entry to the EventLog.
               myNewLog.WriteEntry("The Latest entry in the
 Event Log");
            int myEntries = myNewLog.Entries.Count;
            EventLogEntry entry =myNewLog.Entries[myEntries-1];
            EntryWrittenEventArgs myEntryEventArgs=
                                 new EntryWrittenEventArgs();
            MyOnEntry(myNewLog,myEntryEventArgs);
         }
         catch(Exception e)
         {
            Console.WriteLine("Exception Raised" +e.Message);
         }
      }
      protected static void
 MyOnEntry(Object source, EntryWrittenEventArgs e)
      {
         if(e.Entry == null)
            Console.WriteLine("A new entry is written in
 MyNewLog.");
      }
   }
#using <System.dll>

using namespace System;
using namespace System::Diagnostics;

void MyOnEntry( Object^ source, EntryWrittenEventArgs^ e )
{
   if ( !e->Entry )
      Console::WriteLine( "A new entry is written in
 MyNewLog." );
}

int main()
{
   try
   {
      EventLog^ myNewLog = gcnew EventLog;
      myNewLog->Log = "MyNewLog";
      myNewLog->Source = "MySource";
      
      // Create the source if it does not exist already.
      if (  !EventLog::SourceExists( "MySource" ) )
      {
         EventLog::CreateEventSource( "MySource", "MyNewLog"
 );
         Console::WriteLine( "CreatingEventSource" );
      }
      
      // Write an entry to the EventLog.
      myNewLog->WriteEntry( "The Latest entry in the Event
 Log" );
      int myEntries = myNewLog->Entries->Count;
      EventLogEntry^ entry = myNewLog->Entries[ myEntries - 1 ];
      EntryWrittenEventArgs^ myEntryEventArgs = gcnew EntryWrittenEventArgs;
      MyOnEntry( myNewLog, myEntryEventArgs );
   }
   catch ( Exception^ e ) 
   {
      Console::WriteLine( "Exception Raised{0}", e->Message );
   }
}
import System.*;
import System.Diagnostics.*;

class MySample
{
    public static void main(String[]
 args)
    {
        try {
            EventLog myNewLog = new EventLog();
            myNewLog.set_Log("MyNewLog");
            myNewLog.set_Source("MySource");

            // Create the source if it does not exist already.
            if (!(EventLog.SourceExists("MySource")))
 {
                EventLog.CreateEventSource("MySource", "MyNewLog");
                Console.WriteLine("CreatingEventSource");
            }
            // Write an entry to the EventLog.
            myNewLog.WriteEntry("The Latest entry in the
 Event Log");
            int myEntries = myNewLog.get_Entries().get_Count();
            EventLogEntry entry = myNewLog.get_Entries().
                get_Item((myEntries - 1));
            EntryWrittenEventArgs myEntryEventArgs = new EntryWrittenEventArgs();
            MyOnEntry(myNewLog, myEntryEventArgs);
        }
        catch (System.Exception e) {
            Console.WriteLine("Exception Raised" + e.get_Message());
        }
    } //main

    private static void
 MyOnEntry(Object source, EntryWrittenEventArgs e)
    {
        if (e.get_Entry() == null) {
            Console.WriteLine("A new entry is written in
 MyNewLog.");
        }
    } //MyOnEntry
} //MySample
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
EntryWrittenEventArgs クラス
EntryWrittenEventArgs メンバ
System.Diagnostics 名前空間



英和和英テキスト翻訳>> Weblio翻訳
英語⇒日本語日本語⇒英語
  

辞書ショートカット

すべての辞書の索引

「EntryWrittenEventArgs コンストラクタ」の関連用語

EntryWrittenEventArgs コンストラクタのお隣キーワード
検索ランキング

   

英語⇒日本語
日本語⇒英語
   



EntryWrittenEventArgs コンストラクタのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

   
日本マイクロソフト株式会社日本マイクロソフト株式会社
© 2024 Microsoft.All rights reserved.

©2024 GRAS Group, Inc.RSS