ManagementBaseObject.ClassPath 属性

定义

获取管理对象类的路径。

public:
 virtual property System::Management::ManagementPath ^ ClassPath { System::Management::ManagementPath ^ get(); };
public virtual System.Management.ManagementPath ClassPath { get; }
member this.ClassPath : System.Management.ManagementPath
Public Overridable ReadOnly Property ClassPath As ManagementPath

属性值

管理对象的 类的类路径。

示例

以下示例代码列出了 root\CIMV2 命名空间中具有其类路径的所有类。

对于 \\MyBox\root\cimv2:Win32_LogicalDisk= 'C:' 对象,类路径为 \\MyBox\root\cimv2:Win32_LogicalDisk。

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {
        // Create a query for classes
        SelectQuery query =
            new SelectQuery("SELECT * FROM meta_class");

        // Initialize an object searcher with this query
        ManagementObjectSearcher searcher =
            new ManagementObjectSearcher(query);

        // Get the resulting collection and loop through it
        foreach (ManagementObject classObject in searcher.Get())
        {
            Console.WriteLine(
                classObject.ClassPath);
        }
    }
}
Imports System.Management

Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Create a query for classes
        Dim query As New SelectQuery( _
            "SELECT * FROM meta_class")

        ' Initialize an object searcher with this query
        Dim searcher As New ManagementObjectSearcher( _
            query)

        ' Get the resulting collection and loop through it
        For Each classObject As ManagementObject _
            In searcher.Get()

            Console.WriteLine( _
                classObject.ClassPath)
        Next

    End Function
End Class

注解

属性值

一个 ManagementPath ,它表示管理对象的类的路径。

.NET Framework 安全性

对直接调用方的完全信任。 此成员不能由部分信任的代码使用。 有关详细信息,请参阅 使用部分受信任的代码中的库

适用于