ManagementObject.Scope 屬性
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得或設定該物件所處的範圍。
public:
property System::Management::ManagementScope ^ Scope { System::Management::ManagementScope ^ get(); void set(System::Management::ManagementScope ^ value); };
public System.Management.ManagementScope Scope { get; set; }
member this.Scope : System.Management.ManagementScope with get, set
Public Property Scope As ManagementScope
屬性值
這個物件所處的範圍。
範例
以下範例以預設命名空間初始化類別的新實例 ManagementObject ,然後更改 的範圍 ManagementObject。
using System;
using System.Management;
public class Sample
{
public static void Main()
{
// Create the object with the default namespace
// (root\cimv2)
ManagementObject o = new ManagementObject();
// Change the scope (=namespace) of this object
// to the one specified.
o.Scope = new ManagementScope("root\\CIMV2");
}
}
Imports System.Management
Public Class Sample
Public Overloads Shared Function Main( _
ByVal args() As String) As Integer
' Create the object with the default namespace
' (root\cimv2)
Dim o As New ManagementObject
' Change the scope (=namespace) of this object
' to the one specified.
o.Scope = New ManagementScope("root\CIMV2")
Return 0
End Function
End Class
備註
在管理物件綁定到特定命名空間中的 WMI 物件後,若更改此屬性,則會釋放原本的 WMI 物件。 這會導致管理物件被重新綁定到由新路徑屬性和作用域值指定的新物件。
重新綁定以「懶惰」方式執行,也就是只有當請求的值需要管理物件綁定到 WMI 物件時才會進行。 在嘗試重新綁定前,可以對不只此屬性進行變更(例如同時修改作用域與路徑屬性)。
.NET Framework 安全性
完全信任當下的來電者。 此成員無法被部分受信任的程式碼使用。 欲了解更多資訊,請參閱 「部分受信任程式碼的函式庫使用」。