ManagementPath クラス

定義

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

public ref class ManagementPath : ICloneable
[System.ComponentModel.TypeConverter(typeof(System.Management.ManagementPathConverter))]
public class ManagementPath : 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()

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

適用対象