共用方式為


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

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

適用於