ManagementClass クラスの新しいインスタンスを初期化します。このクラスは、ディスク ドライブを表す Win32_LogicalDisk、Notepad.exe などのプロセスを表す Win32_Process など、WMI の CIM (Common Information Model) 管理クラスを表します。詳細については、MSDN ライブラリ (https://msdn.microsoft.com/library/ja) の Windows Management Instrumentation に関するドキュメントで Win32 クラスのトピックを参照してください。
名前空間: System.Management
アセンブリ: System.Management (system.management.dll 内)
構文
'宣言
Public Sub New ( _
path As ManagementPath _
)
'使用
Dim path As ManagementPath
Dim instance As New ManagementClass(path)
public ManagementClass (
ManagementPath path
)
public:
ManagementClass (
ManagementPath^ path
)
public ManagementClass (
ManagementPath path
)
public function ManagementClass (
path : ManagementPath
)
パラメータ
- path
バインド先の WMI クラスを指定する ManagementPath。このパラメータには、WMI (Windows Management Instrumentation) クラス パスを指定する必要があります。クラスは、WMI の CIM 管理クラスを表します。CIM クラスは、ハードウェア、ソフトウェア、プロセスなどの管理情報を表します。Windows で使用できる CIM クラスの詳細については、MSDN ライブラリ (https://msdn.microsoft.com/library/ja) の Windows Management Instrumentation に関するドキュメントで Win32 クラスのトピックを参照してください。
解説
path パラメータでは、WMI (Windows Management Instrumentation) クラス パスを指定する必要があります。
.NET Framework のセキュリティ
直前の呼び出し元に対する完全な信頼。このメンバは、信頼性が一部しか確認されていないコードでは使用できません。詳細については、「部分信頼コードからのライブラリの使用」を参照してください。
使用例
ManagementClass コンストラクタを使用して、ManagementClass 変数を初期化する方法の例を次に示します。この例では、作成されたクラスのメソッド、プロパティ、および修飾子を一覧表示します。
Imports System
Imports System.Management
Class Sample
Public Overloads Shared Function _
Main(ByVal args() As String) As Integer
' Get the WMI class
Dim c As New ManagementClass( _
New ManagementPath("Win32_LogicalDisk"))
' Get the methods in the class
Dim methods As MethodDataCollection
methods = c.Methods
' display the methods
Console.WriteLine("Method Names: ")
For Each method As MethodData In methods
Console.WriteLine(method.Name)
Next
Console.WriteLine()
' Get the properties in the class
Dim properties As PropertyDataCollection
properties = c.Properties
' display the properties
Console.WriteLine("Property Names: ")
For Each p As PropertyData In properties
Console.WriteLine(p.Name)
Next
Console.WriteLine()
' Get the Qualifiers in the class
Dim qualifiers As QualifierDataCollection = _
c.Qualifiers()
' display the qualifiers
Console.WriteLine("Qualifier Names: ")
For Each qualifier As QualifierData In qualifiers
Console.WriteLine(qualifier.Name)
Next
End Function
End Class
using System;
using System.Management;
public class Sample
{
public static void Main()
{
// Get the WMI class
ManagementClass c = new ManagementClass(
new ManagementPath("Win32_LogicalDisk"));
// Get the methods in the class
MethodDataCollection methods =
c.Methods;
// display the methods
Console.WriteLine("Method Names: ");
foreach (MethodData method in methods)
{
Console.WriteLine(method.Name);
}
Console.WriteLine();
// Get the properties in the class
PropertyDataCollection properties =
c.Properties;
// display the properties
Console.WriteLine("Property Names: ");
foreach (PropertyData property in properties)
{
Console.WriteLine(property.Name);
}
Console.WriteLine();
// Get the Qualifiers in the class
QualifierDataCollection qualifiers =
c.Qualifiers;
// display the qualifiers
Console.WriteLine("Qualifier Names: ");
foreach (QualifierData qualifier in qualifiers)
{
Console.WriteLine(qualifier.Name);
}
}
}
.NET Framework のセキュリティ
- 直前の呼び出し元に対する完全な信頼。このメンバは、部分的に信頼されているコードから使用することはできません。詳細については、「」を参照してください。
プラットフォーム
Windows 98, Windows 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition
開発プラットフォームの中には、.NET Framework によってサポートされていないバージョンがあります。サポートされているバージョンについては、「システム要件」を参照してください。
バージョン情報
.NET Framework
サポート対象 : 2.0、1.1、1.0
参照
関連項目
ManagementClass クラス
ManagementClass メンバ
System.Management 名前空間