ManagementPath クラス

定義

WMI (Windows Management Instrumentation) オブジェクトへのパスを解析および構築するためのラッパーを提供します。

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
継承
ManagementPath
属性
実装

次の例では、 クラスが ManagementPath WMI オブジェクトへのパスを解析する方法を示します。 この例で解析されるパスは、 クラスのインスタンスへのパスです。

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

コンストラクター

ManagementPath()

ManagementPath クラスの新しい空のインスタンスを初期化します。 これはパラメーターなしのコンストラクターです。

ManagementPath(String)

特定パスの ManagementPath クラスの新しいインスタンスを初期化します。

プロパティ

ClassName

パスのクラス部分を取得または設定します。

DefaultPath

スコープが指定されない場合に使用する既定のスコープ パスを取得または設定します。 既定のスコープは \\.\root\cimv2 であり、このプロパティを設定することで変更できます。

IsClass

クラス パスかどうかを示す値を取得または設定します。

IsInstance

インスタンス パスかどうかを示す値を取得または設定します。

IsSingleton

シングルトン インスタンス パスかどうかを示す値を取得または設定します。

NamespacePath

パスの名前空間部分を取得または設定します。 別個に取得できるサーバー名は含まれていないことに注意してください。

Path

オブジェクトの完全パスの文字列形式を取得または設定します。

RelativePath

相対パス、つまりクラス名とキーだけを取得または設定します。

Server

パスのサーバー部分を取得または設定します。

メソッド

Clone()

ManagementPath のコピーを返します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
SetAsClass()

新しいクラス パスとしてパスを設定します。 つまり、パスにキー値ではなく、クラス名を要求します。

SetAsSingleton()

新しいシングルトン オブジェクト パスとしてパスを設定します。 つまり、これはインスタンスへのパスですが、キー値はありません。

ToString()

オブジェクトの完全パスを文字列形式として返します。

明示的なインターフェイスの実装

ICloneable.Clone()

現在のインスタンスのコピーである新しいオブジェクトを作成します。

適用対象