ManagementPath Konstruktory

Definicja

Inicjuje nowe wystąpienie klasy ManagementPath.

Przeciążenia

Nazwa Opis
ManagementPath()

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

ManagementPath(String)

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

ManagementPath()

Źródło:
ManagementPath.cs
Źródło:
ManagementPath.cs
Źródło:
ManagementPath.cs
Źródło:
ManagementPath.cs

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

public:
 ManagementPath();
public ManagementPath();
Public Sub New ()

Uwagi

Zabezpieczenia programu .NET Framework

Pełne zaufanie dla bezpośredniego obiektu wywołującego. Tego elementu członkowskiego nie można używać przez częściowo zaufany kod. Aby uzyskać więcej informacji, zobacz Using Libraries from Partially Trusted Code (Używanie bibliotek z częściowo zaufanego kodu).

Dotyczy

ManagementPath(String)

Źródło:
ManagementPath.cs
Źródło:
ManagementPath.cs
Źródło:
ManagementPath.cs
Źródło:
ManagementPath.cs

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

public:
 ManagementPath(System::String ^ path);
public ManagementPath(string path);
new System.Management.ManagementPath : string -> System.Management.ManagementPath
Public Sub New (path As String)

Parametry

path
String

Ścieżka obiektu.

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

Uwagi

Zabezpieczenia programu .NET Framework

Pełne zaufanie dla bezpośredniego obiektu wywołującego. Tego elementu członkowskiego nie można używać przez częściowo zaufany kod. Aby uzyskać więcej informacji, zobacz Using Libraries from Partially Trusted Code (Używanie bibliotek z częściowo zaufanego kodu).

Dotyczy