Bagikan melalui


ManagementBaseObject.ClassPath Properti

Definisi

Mendapatkan jalur ke kelas objek manajemen.

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

Nilai Properti

Jalur kelas ke kelas objek manajemen.

Contoh

Contoh kode berikut mencantumkan semua kelas dengan jalur kelasnya di namespace root\CIMV2.

Untuk objek \\MyBox\root\cimv2:Win32_LogicalDisk= 'C:', jalur kelasnya adalah \\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

Keterangan

Nilai Properti

ManagementPath yang mewakili jalur ke kelas objek manajemen.

.NET Framework Security

Kepercayaan penuh untuk penelepon segera. Anggota ini tidak dapat digunakan oleh kode tepercaya sebagian. Untuk informasi selengkapnya, lihat Menggunakan Pustaka dari Kode Tepercaya Sebagian.

Berlaku untuk