MethodData クラス
WMI (Windows Management Instrumentation) メソッドに関する情報を格納します。
この型のすべてのメンバの一覧については、MethodData メンバ を参照してください。
System.Object
System.Management.MethodData
Public Class MethodData
[C#]
public class MethodData
[C++]
public __gc class MethodData
[JScript]
public class MethodData
スレッドセーフ
この型の public static (Visual Basicでは Shared) のすべてのメンバは、マルチスレッド操作で安全に使用できます。インスタンスのメンバの場合は、スレッドセーフであるとは限りません。
使用例
using System;
using System.Management;
// This example shows how to obtain meta data
// about a WMI method with a given name in a given WMI class
class Sample_MethodData
{
public static int Main(string[] args) {
// Get the "SetPowerState" method in the Win32_LogicalDisk class
ManagementClass diskClass = new ManagementClass("win32_logicaldisk");
MethodData m = diskClass.Methods["SetPowerState"];
// Get method name (albeit we already know it)
Console.WriteLine("Name: " + m.Name);
// Get the name of the top-most class where this specific method was defined
Console.WriteLine("Origin: " + m.Origin);
// List names and types of input parameters
ManagementBaseObject inParams = m.InParameters;
foreach(PropertyData pdata in inParams.Properties) {
Console.WriteLine();
Console.WriteLine("InParam_Name: " + pdata.Name);
Console.WriteLine("InParam_Type: " + pdata.Type);
}
// List names and types of output parameters
ManagementBaseObject outParams = m.OutParameters;
foreach(PropertyData pdata in outParams.Properties) {
Console.WriteLine();
Console.WriteLine("OutParam_Name: " + pdata.Name);
Console.WriteLine("OutParam_Type: " + pdata.Type);
}
return 0;
}
}
[Visual Basic]
Imports System
Imports System.Management
' This example shows how to obtain meta data
' about a WMI method with a given name in a given WMI class
Class Sample_ManagementClass
Overloads Public Shared Function Main(args() As String) As Integer
' Get the "SetPowerState" method in the Win32_LogicalDisk class
Dim diskClass As New ManagementClass("Win32_LogicalDisk")
Dim m As MethodData = diskClass.Methods("SetPowerState")
' Get method name (albeit we already know it)
Console.WriteLine("Name: " & m.Name)
' Get the name of the top-most class where
' this specific method was defined
Console.WriteLine("Origin: " & m.Origin)
' List names and types of input parameters
Dim inParams As ManagementBaseObject
inParams = m.InParameters
Dim pdata As PropertyData
For Each pdata In inParams.Properties
Console.WriteLine()
Console.WriteLine("InParam_Name: " & pdata.Name)
Console.WriteLine("InParam_Type: " & pdata.Type)
Next pdata
' List names and types of output parameters
Dim outParams As ManagementBaseObject
outParams = m.OutParameters
For Each pdata in outParams.Properties
Console.WriteLine()
Console.WriteLine("OutParam_Name: " & pdata.Name)
Console.WriteLine("OutParam_Type: " & pdata.Type)
Next pdata
Return 0
End Function
End Class
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
必要条件
名前空間: System.Management
プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ
アセンブリ: System.Management (System.Management.dll 内)