ManagementObject.Scope 屬性

定義

取得或設定這個物件所在處的範圍。Gets or sets the scope in which this object resides.

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

屬性值

ManagementScope

這個物件所在的範圍。The scope in which this object resides.

範例

下列範例會使用預設的命名空間來初始化類別的新實例 ManagementObject ,然後變更的範圍 ManagementObjectThe following example initializes a new instance of the ManagementObject class with the default namespace, and then changes the scope of the 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 物件。Changing this property after the management object has been bound to a WMI object in a particular namespace results in releasing the original WMI object. 這會導致管理物件重新綁定至新的路徑屬性和範圍值所指定的新物件。This causes the management object to be rebound to the new object specified by the new path properties and scope values.

重新系結會以「延遲」的方式執行,也就是只有在要求的值需要將管理物件系結至 WMI 物件時。The rebinding is performed in a "lazy" manner, that is, only when a requested value requires the management object to be bound to the WMI object. 在嘗試重新系結 ((例如,) 同時修改範圍和路徑屬性)之前,不只可以對此屬性進行變更。Changes can be made to more than just this property before attempting to rebind (for example, modifying the scope and path properties simultaneously).

.NET Framework 安全性.NET Framework Security

完全信任立即呼叫者。Full trust for the immediate caller. 這個成員無法供部分信任的程式碼使用。This member cannot be used by partially trusted code. 如需詳細資訊,請參閱 使用來自部分信任程式碼的程式庫For more information, see Using Libraries from Partially Trusted Code.

適用於