EventQuery クラス
アセンブリ: System.Management (system.management.dll 内)


イベント クラスが __InstanceCreationEvent であるために、Win32_Process のインスタンスが作成されたときにクライアントが通知を受信するしくみを説明する例を次に示します。詳細については、MSDN ライブラリ (http://msdn.microsoft.com/library/ja) で Windows Management Instrumentation に関するドキュメントを参照してください。クライアントは WaitForNextEvent メソッドを呼び出して、イベントを同期的に受信します。この例は、コード例の実行中にメモ帳などのプロセスを開始することでテストできます。
Imports System Imports System.Management ' This example shows synchronous consumption of events. ' The client is blocked while waiting for events. Public Class EventWatcherPolling Public Overloads Shared Function _ Main(ByVal args() As String) As Integer ' Create event query to be notified within 1 second of ' a change in a service Dim query As New EventQuery query.QueryString = "SELECT * FROM" & _ " __InstanceCreationEvent WITHIN 1 " & _ "WHERE TargetInstance isa ""Win32_Process""" ' Initialize an event watcher and subscribe to events ' that match this query Dim watcher As New ManagementEventWatcher(query) ' times watcher.WaitForNextEvent in 5 seconds watcher.Options.Timeout = New TimeSpan(0, 0, 50) ' Block until the next event occurs ' Note: this can be done in a loop ' if waiting for more than one occurrence Console.WriteLine( _ "Open an application (notepad.exe) to trigger an event.") Dim e As ManagementBaseObject = _ watcher.WaitForNextEvent() 'Display information from the event Console.WriteLine( _ "Process {0} has created, path is: {1}", _ CType(e("TargetInstance"), _ ManagementBaseObject)("Name"), _ CType(e("TargetInstance"), _ ManagementBaseObject)("ExecutablePath")) 'Cancel the subscription watcher.Stop() Return 0 End Function 'Main End Class 'EventWatcherPolling
using System; using System.Management; // This example shows synchronous consumption of events. // The client is blocked while waiting for events. public class EventWatcherPolling { public static int Main(string[] args) { // Create event query to be notified within 1 second of // a change in a service EventQuery query = new EventQuery(); query.QueryString = "SELECT * FROM" + " __InstanceCreationEvent WITHIN 1 " + "WHERE TargetInstance isa \"Win32_Process\""; // Initialize an event watcher and subscribe to events // that match this query ManagementEventWatcher watcher = new ManagementEventWatcher(query); // times out watcher.WaitForNextEvent in 5 seconds watcher.Options.Timeout = new TimeSpan(0,0,5); // Block until the next event occurs // Note: this can be done in a loop if waiting for // more than one occurrence Console.WriteLine( "Open an application (notepad.exe) to trigger an event."); ManagementBaseObject e = watcher.WaitForNextEvent(); //Display information from the event Console.WriteLine( "Process {0} has been created, path is: {1}", ((ManagementBaseObject)e ["TargetInstance"])["Name"], ((ManagementBaseObject)e ["TargetInstance"])["ExecutablePath"]); //Cancel the subscription watcher.Stop(); return 0; } }

System.Management.ManagementQuery
System.Management.EventQuery
System.Management.WqlEventQuery


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


EventQuery コンストラクタ ()
アセンブリ: System.Management (system.management.dll 内)


イベント クラスが __InstanceCreationEvent であるために、Win32_Process のインスタンスが作成されたときにクライアントが通知を受信するしくみを説明する例を次に示します。詳細については、MSDN ライブラリ (http://msdn.microsoft.com/library/ja) で Windows Management Instrumentation に関するドキュメントを参照してください。クライアントは WaitForNextEvent メソッドを呼び出して、イベントを同期的に受信します。この例は、コード例の実行中にメモ帳などのプロセスを開始することでテストできます。
Imports System Imports System.Management ' This example shows synchronous consumption of events. ' The client is blocked while waiting for events. Public Class EventWatcherPolling Public Overloads Shared Function _ Main(ByVal args() As String) As Integer ' Create event query to be notified within 1 second of ' a change in a service Dim query As New EventQuery query.QueryString = "SELECT * FROM" & _ " __InstanceCreationEvent WITHIN 1 " & _ "WHERE TargetInstance isa ""Win32_Process""" ' Initialize an event watcher and subscribe to events ' that match this query Dim watcher As New ManagementEventWatcher(query) ' times watcher.WaitForNextEvent in 5 seconds watcher.Options.Timeout = New TimeSpan(0, 0, 50) ' Block until the next event occurs ' Note: this can be done in a loop ' if waiting for more than one occurrence Console.WriteLine( _ "Open an application (notepad.exe) to trigger an event.") Dim e As ManagementBaseObject = _ watcher.WaitForNextEvent() 'Display information from the event Console.WriteLine( _ "Process {0} has created, path is: {1}", _ CType(e("TargetInstance"), _ ManagementBaseObject)("Name"), _ CType(e("TargetInstance"), _ ManagementBaseObject)("ExecutablePath")) 'Cancel the subscription watcher.Stop() Return 0 End Function 'Main End Class 'EventWatcherPolling
using System; using System.Management; // This example shows synchronous consumption of events. // The client is blocked while waiting for events. public class EventWatcherPolling { public static int Main(string[] args) { // Create event query to be notified within 1 second of // a change in a service EventQuery query = new EventQuery(); query.QueryString = "SELECT * FROM" + " __InstanceCreationEvent WITHIN 1 " + "WHERE TargetInstance isa \"Win32_Process\""; // Initialize an event watcher and subscribe to events // that match this query ManagementEventWatcher watcher = new ManagementEventWatcher(query); // times out watcher.WaitForNextEvent in 5 seconds watcher.Options.Timeout = new TimeSpan(0,0,5); // Block until the next event occurs // Note: this can be done in a loop if waiting for // more than one occurrence Console.WriteLine( "Open an application (notepad.exe) to trigger an event."); ManagementBaseObject e = watcher.WaitForNextEvent(); //Display information from the event Console.WriteLine( "Process {0} has been created, path is: {1}", ((ManagementBaseObject)e ["TargetInstance"])["Name"], ((ManagementBaseObject)e ["TargetInstance"])["ExecutablePath"]); //Cancel the subscription watcher.Stop(); return 0; } }


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


EventQuery コンストラクタ (String)
アセンブリ: System.Management (system.management.dll 内)


イベント クラスが __InstanceCreationEvent であるために、Win32_Process のインスタンスが作成されたときにクライアントが通知を受信するしくみを説明する例を次に示します。詳細については、MSDN ライブラリ (http://msdn.microsoft.com/library/ja) で Windows Management Instrumentation に関するドキュメントを参照してください。クライアントは WaitForNextEvent メソッドを呼び出して、イベントを同期的に受信します。この例は、コード例の実行中にメモ帳などのプロセスを開始することでテストできます。
Imports System Imports System.Management ' This example shows synchronous consumption of events. ' The client is blocked while waiting for events. Public Class EventWatcherPolling Public Overloads Shared Function _ Main(ByVal args() As String) As Integer ' Create event query to be notified within 1 second of ' a change in a service Dim query As New EventQuery( _ "SELECT * FROM" & _ " __InstanceCreationEvent WITHIN 1 " & _ "WHERE TargetInstance isa ""Win32_Process""") ' Initialize an event watcher and subscribe to events ' that match this query Dim watcher As New ManagementEventWatcher(query) ' times watcher.WaitForNextEvent in 5 seconds watcher.Options.Timeout = New TimeSpan(0, 0, 50) ' Block until the next event occurs ' Note: this can be done in a loop ' if waiting for more than one occurrence Console.WriteLine( _ "Open an application (notepad.exe) to trigger an event.") Dim e As ManagementBaseObject = _ watcher.WaitForNextEvent() 'Display information from the event Console.WriteLine( _ "Process {0} has created, path is: {1}", _ CType(e("TargetInstance"), _ ManagementBaseObject)("Name"), _ CType(e("TargetInstance"), _ ManagementBaseObject)("ExecutablePath")) 'Cancel the subscription watcher.Stop() Return 0 End Function 'Main End Class 'EventWatcherPolling
using System; using System.Management; // This example shows synchronous consumption of events. // The client is blocked while waiting for events. public class EventWatcherPolling { public static int Main(string[] args) { // Create event query to be notified within 1 second of // a change in a service EventQuery query = new EventQuery( "SELECT * FROM" + " __InstanceCreationEvent WITHIN 1 " + "WHERE TargetInstance isa \"Win32_Process\""); // Initialize an event watcher and subscribe to events // that match this query ManagementEventWatcher watcher = new ManagementEventWatcher(query); // times out watcher.WaitForNextEvent in 5 seconds watcher.Options.Timeout = new TimeSpan(0,0,5); // Block until the next event occurs // Note: this can be done in a loop if waiting for // more than one occurrence Console.WriteLine( "Open an application (notepad.exe) to trigger an event."); ManagementBaseObject e = watcher.WaitForNextEvent(); //Display information from the event Console.WriteLine( "Process {0} has been created, path is: {1}", ((ManagementBaseObject)e ["TargetInstance"])["Name"], ((ManagementBaseObject)e ["TargetInstance"])["ExecutablePath"]); //Cancel the subscription watcher.Stop(); return 0; } }


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


EventQuery コンストラクタ (String, String)
アセンブリ: System.Management (system.management.dll 内)


イベント クラスが __InstanceCreationEvent であるために、Win32_Process のインスタンスが作成されたときにクライアントが通知を受信するしくみを説明する例を次に示します。詳細については、MSDN ライブラリ (http://msdn.microsoft.com/library/ja) で Windows Management Instrumentation に関するドキュメントを参照してください。クライアントは WaitForNextEvent メソッドを呼び出して、イベントを同期的に受信します。この例は、コード例の実行中にメモ帳などのプロセスを開始することでテストできます。
Imports System Imports System.Management ' This example shows synchronous consumption of events. ' The client is blocked while waiting for events. Public Class EventWatcherPolling Public Overloads Shared Function _ Main(ByVal args() As String) As Integer ' Create event query to be notified within 1 second of ' a change in a service Dim query As New EventQuery("WQL", _ "SELECT * FROM" & _ " __InstanceCreationEvent WITHIN 1 " & _ "WHERE TargetInstance isa ""Win32_Process""") ' Initialize an event watcher and subscribe to events ' that match this query Dim watcher As New ManagementEventWatcher(query) ' times watcher.WaitForNextEvent in 5 seconds watcher.Options.Timeout = New TimeSpan(0, 0, 50) ' Block until the next event occurs ' Note: this can be done in a loop ' if waiting for more than one occurrence Console.WriteLine( _ "Open an application (notepad.exe) to trigger an event.") Dim e As ManagementBaseObject = _ watcher.WaitForNextEvent() 'Display information from the event Console.WriteLine( _ "Process {0} has created, path is: {1}", _ CType(e("TargetInstance"), _ ManagementBaseObject)("Name"), _ CType(e("TargetInstance"), _ ManagementBaseObject)("ExecutablePath")) 'Cancel the subscription watcher.Stop() Return 0 End Function 'Main End Class 'EventWatcherPolling
using System; using System.Management; // This example shows synchronous consumption of events. // The client is blocked while waiting for events. public class EventWatcherPolling { public static int Main(string[] args) { // Create event query to be notified within 1 second of // a change in a service EventQuery query = new EventQuery("WQL", "SELECT * FROM" + " __InstanceCreationEvent WITHIN 1 " + "WHERE TargetInstance isa \"Win32_Process\""); // Initialize an event watcher and subscribe to events // that match this query ManagementEventWatcher watcher = new ManagementEventWatcher(query); // times out watcher.WaitForNextEvent in 5 seconds watcher.Options.Timeout = new TimeSpan(0,0,5); // Block until the next event occurs // Note: this can be done in a loop if waiting for // more than one occurrence Console.WriteLine( "Open an application (notepad.exe) to trigger an event."); ManagementBaseObject e = watcher.WaitForNextEvent(); //Display information from the event Console.WriteLine( "Process {0} has been created, path is: {1}", ((ManagementBaseObject)e ["TargetInstance"])["Name"], ((ManagementBaseObject)e ["TargetInstance"])["ExecutablePath"]); //Cancel the subscription watcher.Stop(); return 0; } }


Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。


EventQuery コンストラクタ

名前 | 説明 |
---|---|
EventQuery () | EventQuery クラスの新しいインスタンスを初期化します。これは既定のコンストラクタです。 |
EventQuery (String) | 指定したクエリの EventQuery クラスの新しいインスタンスを初期化します。 |
EventQuery (String, String) | 指定した言語とクエリの EventQuery クラスの新しいインスタンスを初期化します。 |

EventQuery プロパティ

名前 | 説明 | |
---|---|---|
![]() | QueryLanguage | クエリ文字列の書式を定義して、クエリ文字列で使用するクエリ言語を取得または設定します。 ( ManagementQuery から継承されます。) |
![]() | QueryString | テキスト形式でクエリを取得または設定します。 ( ManagementQuery から継承されます。) |

EventQuery メソッド

名前 | 説明 | |
---|---|---|
![]() | Clone | オーバーライドされます。 オブジェクトのコピーを返します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 ( Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 ( Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 ( Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 ( Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 ( Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 ( Object から継承されます。) |
![]() | GetValueOfKeyword | ( ManagementQuery から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 ( Object から継承されます。) |
![]() | ParseQuery | クエリ文字列を解析し、その結果に応じてプロパティ値を設定します。クエリが有効な場合は、クエリのクラス名プロパティおよび条件プロパティが解析されます。 ( ManagementQuery から継承されます。) |

EventQuery メンバ
WMI (Windows Management Instrumentation) イベント クエリを表します。
EventQuery データ型で公開されるメンバを以下の表に示します。


名前 | 説明 | |
---|---|---|
![]() | QueryLanguage | クエリ文字列の書式を定義して、クエリ文字列で使用するクエリ言語を取得または設定します。 (ManagementQuery から継承されます。) |
![]() | QueryString | テキスト形式でクエリを取得または設定します。 (ManagementQuery から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Clone | オーバーライドされます。 オブジェクトのコピーを返します。 |
![]() | Equals | オーバーロードされます。 2 つの Object インスタンスが等しいかどうかを判断します。 (Object から継承されます。) |
![]() | GetHashCode | 特定の型のハッシュ関数として機能します。GetHashCode は、ハッシュ アルゴリズムや、ハッシュ テーブルのようなデータ構造での使用に適しています。 (Object から継承されます。) |
![]() | GetType | 現在のインスタンスの Type を取得します。 (Object から継承されます。) |
![]() | ReferenceEquals | 指定した複数の Object インスタンスが同一かどうかを判断します。 (Object から継承されます。) |
![]() | ToString | 現在の Object を表す String を返します。 (Object から継承されます。) |

名前 | 説明 | |
---|---|---|
![]() | Finalize | Object がガベージ コレクションにより収集される前に、その Object がリソースを解放し、その他のクリーンアップ操作を実行できるようにします。 (Object から継承されます。) |
![]() | GetValueOfKeyword | ( ManagementQuery から継承されます。) |
![]() | MemberwiseClone | 現在の Object の簡易コピーを作成します。 (Object から継承されます。) |
![]() | ParseQuery | クエリ文字列を解析し、その結果に応じてプロパティ値を設定します。クエリが有効な場合は、クエリのクラス名プロパティおよび条件プロパティが解析されます。 (ManagementQuery から継承されます。) |

Weblioに収録されているすべての辞書からEventQueryを検索する場合は、下記のリンクをクリックしてください。

- EventQueryのページへのリンク