ManagementPath Constructeurs

Définition

Initialise une nouvelle instance de la classe ManagementPath.

Surcharges

ManagementPath()

Initialise une nouvelle instance de la classe ManagementPath qui est vide. Il s’agit du constructeur sans paramètre.

ManagementPath(String)

Initialise une nouvelle instance de la classe ManagementPath pour le chemin d'accès spécifié.

ManagementPath()

Source:
ManagementPath.cs
Source:
ManagementPath.cs
Source:
ManagementPath.cs

Initialise une nouvelle instance de la classe ManagementPath qui est vide. Il s’agit du constructeur sans paramètre.

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

Remarques

Sécurité du .NET Framework

Confiance totale accordée à l'appelant immédiat. Ce membre ne peut pas être utilisé par du code d'un niveau de confiance partiel. Pour plus d’informations, consultez Utilisation de bibliothèques à partir de code partiellement approuvé.

S’applique à

ManagementPath(String)

Source:
ManagementPath.cs
Source:
ManagementPath.cs
Source:
ManagementPath.cs

Initialise une nouvelle instance de la classe ManagementPath pour le chemin d'accès spécifié.

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

Paramètres

path
String

Chemin d’accès de l’objet.

Exemples

L’exemple suivant montre comment la ManagementPath classe analyse un chemin d’accès à un objet WMI. Le chemin d’accès analysé dans l’exemple est un chemin d’accès à une instance d’une classe.

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

Remarques

Sécurité du .NET Framework

Confiance totale accordée à l'appelant immédiat. Ce membre ne peut pas être utilisé par du code d'un niveau de confiance partiel. Pour plus d’informations, consultez Utilisation de bibliothèques à partir de code partiellement approuvé.

S’applique à