ManagementPath Klasa

Definicja

Udostępnia otokę do analizowania i tworzenia ścieżek do obiektów WMI.

public ref class ManagementPath : ICloneable
public class ManagementPath : ICloneable
[System.ComponentModel.TypeConverter(typeof(System.Management.ManagementPathConverter))]
public class ManagementPath : ICloneable
type ManagementPath = class
    interface ICloneable
[<System.ComponentModel.TypeConverter(typeof(System.Management.ManagementPathConverter))>]
type ManagementPath = class
    interface ICloneable
Public Class ManagementPath
Implements ICloneable
Dziedziczenie
ManagementPath
Atrybuty
Implementuje

Przykłady

W poniższym przykładzie pokazano, jak ManagementPath klasa analizuje ścieżkę do obiektu WMI. Ścieżka analizowana w przykładzie jest ścieżką do wystąpienia klasy.

using System;
using System.Management;

public class Sample
{
    public static void Main()
    {

        // Get the WMI class path
        ManagementPath p =
            new ManagementPath(
            "\\\\ComputerName\\root" +
            "\\cimv2:Win32_LogicalDisk.DeviceID=\"C:\"");

        Console.WriteLine("IsClass: " +
            p.IsClass);
        // Should be False (because it is an instance)

        Console.WriteLine("IsInstance: " +
            p.IsInstance);
        // Should be True

        Console.WriteLine("ClassName: " +
            p.ClassName);
        // Should be "Win32_LogicalDisk"

        Console.WriteLine("NamespacePath: " +
            p.NamespacePath);
        // Should be "ComputerName\cimv2"

        Console.WriteLine("Server: " +
            p.Server);
        // Should be "ComputerName"

        Console.WriteLine("Path: " +
            p.Path);
        // Should be "ComputerName\root\cimv2:
        // Win32_LogicalDisk.DeviceId="C:""

        Console.WriteLine("RelativePath: " +
            p.RelativePath);
        // Should be "Win32_LogicalDisk.DeviceID="C:""
    }
}
Imports System.Management


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

        ' Get the WMI class path
        Dim p As ManagementPath = _
            New ManagementPath( _
            "\\ComputerName\root" & _
            "\cimv2:Win32_LogicalDisk.DeviceID=""C:""")

        Console.WriteLine("IsClass: " & _
            p.IsClass)
        ' Should be False (because it is an instance)

        Console.WriteLine("IsInstance: " & _
            p.IsInstance)
        ' Should be True

        Console.WriteLine("ClassName: " & _
            p.ClassName)
        ' Should be "Win32_LogicalDisk"

        Console.WriteLine("NamespacePath: " & _
            p.NamespacePath)
        ' Should be "ComputerName\cimv2"

        Console.WriteLine("Server: " & _
            p.Server)
        ' Should be "ComputerName"

        Console.WriteLine("Path: " & _
            p.Path)
        ' Should be "ComputerName\root\cimv2:
        ' Win32_LogicalDisk.DeviceId="C:""

        Console.WriteLine("RelativePath: " & _
            p.RelativePath)
        ' Should be "Win32_LogicalDisk.DeviceID="C:""

    End Function
End Class

Konstruktory

ManagementPath()

Inicjuje ManagementPath nowe wystąpienie klasy, która jest pusta. Jest to konstruktor bez parametrów.

ManagementPath(String)

Inicjuje ManagementPath nowe wystąpienie klasy dla danej ścieżki.

Właściwości

ClassName

Pobiera lub ustawia część klasy ścieżki.

DefaultPath

Pobiera lub ustawia domyślną ścieżkę zakresu używaną, gdy nie określono żadnego zakresu. Domyślny zakres to \\.\root\cimv2 i można go zmienić, ustawiając tę właściwość.

IsClass

Pobiera lub ustawia wartość wskazującą, czy jest to ścieżka klasy.

IsInstance

Pobiera lub ustawia wartość wskazującą, czy jest to ścieżka wystąpienia.

IsSingleton

Pobiera lub ustawia wartość wskazującą, czy jest to ścieżka pojedynczego wystąpienia.

NamespacePath

Pobiera lub ustawia część przestrzeni nazw ścieżki. Należy pamiętać, że nie zawiera nazwy serwera, którą można pobrać oddzielnie.

Path

Pobiera lub ustawia reprezentację ciągu pełnej ścieżki w obiekcie.

RelativePath

Pobiera lub ustawia ścieżkę względną: tylko nazwę klasy i klucze.

Server

Pobiera lub ustawia część serwera ścieżki.

Metody

Clone()

Zwraca kopię elementu ManagementPath.

Equals(Object)

Określa, czy dany obiekt jest taki sam, jak bieżący obiekt.

(Odziedziczone po Object)
GetHashCode()

Służy jako domyślna funkcja skrótu.

(Odziedziczone po Object)
GetType()

Type Pobiera bieżące wystąpienie.

(Odziedziczone po Object)
MemberwiseClone()

Tworzy płytkią kopię bieżącego Objectelementu .

(Odziedziczone po Object)
SetAsClass()

Ustawia ścieżkę jako nową ścieżkę klasy. Oznacza to, że ścieżka musi mieć nazwę klasy, ale nie wartości klucza.

SetAsSingleton()

Ustawia ścieżkę jako nową ścieżkę pojedynczego obiektu. Oznacza to, że jest to ścieżka do wystąpienia, ale nie ma żadnych wartości klucza.

ToString()

Zwraca pełną ścieżkę obiektu jako reprezentację ciągu.

Jawne implementacje interfejsu

ICloneable.Clone()

Tworzy nowy obiekt, który jest kopią bieżącego wystąpienia.

Dotyczy