ManagementObject.Scope 屬性

定義

取得或設定這個物件所在處的範圍。

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 安全性

完全信任立即呼叫者。 這個成員無法供部分信任的程式碼使用。 如需詳細資訊,請參閱 使用部分信任程式代碼的連結庫

適用於