ManagementEventWatcher.Scope プロパティとは? わかりやすく解説

Weblio 辞書 > コンピュータ > .NET Framework クラス ライブラリ リファレンス > ManagementEventWatcher.Scope プロパティの意味・解説 

ManagementEventWatcher.Scope プロパティ

イベントウォッチするスコープ (名前空間またはスコープ) を取得または設定します

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

Public Property Scope As
 ManagementScope
Dim instance As ManagementEventWatcher
Dim value As ManagementScope

value = instance.Scope

instance.Scope = value
public ManagementScope Scope { get; set;
 }
public:
property ManagementScope^ Scope {
    ManagementScope^ get ();
    void set (ManagementScope^ value);
}
/** @property */
public ManagementScope get_Scope ()

/** @property */
public void set_Scope (ManagementScope value)
public function get Scope
 () : ManagementScope

public function set Scope
 (value : ManagementScope)

プロパティ
イベントウォッチするスコープ格納している ManagementScope を返します

解説解説
使用例使用例

イベント クラス__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
 WqlEventQuery( _
            "__InstanceCreationEvent", _
            New TimeSpan(0, 0, 1), _
            "TargetInstance isa ""Win32_Process""")

        ' Initialize an event watcher and subscribe to events 
        ' that match this query
        Dim watcher As New
 ManagementEventWatcher
        watcher.Query = query
        watcher.Scope = New ManagementScope("root\CIMV2")
        ' times 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.")
        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
        WqlEventQuery query = 
            new WqlEventQuery("__InstanceCreationEvent",
 
            new TimeSpan(0,0,1), 
            "TargetInstance isa \"Win32_Process\"");

        // Initialize an event watcher and subscribe to events 
        // that match this query
        ManagementEventWatcher watcher =
            new ManagementEventWatcher();
        watcher.Query = query;
        watcher.Scope = new ManagementScope("root\\CIMV2");
        // 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;
    }
}
.NET Framework のセキュリティ.NET Frameworkセキュリティ
プラットフォームプラットフォーム
バージョン情報バージョン情報
参照参照
関連項目
ManagementEventWatcher クラス
ManagementEventWatcher メンバ
System.Management 名前空間



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

辞書ショートカット

すべての辞書の索引

ManagementEventWatcher.Scope プロパティのお隣キーワード
検索ランキング

   

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



ManagementEventWatcher.Scope プロパティのページの著作権
Weblio 辞書 情報提供元は 参加元一覧 にて確認できます。

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

©2024 GRAS Group, Inc.RSS