オブジェクトのメソッドを呼び出します。
オーバーロードの一覧
オブジェクトのメソッドを呼び出します。
[Visual Basic] Overloads Public Function InvokeMethod(String, Object()) As Object
[JScript] public function InvokeMethod(String, Object[]) : Object;
オブジェクトのメソッドを非同期的に呼び出します。
[Visual Basic] Overloads Public Sub InvokeMethod(ManagementOperationObserver, String, Object())
[C#] public void InvokeMethod(ManagementOperationObserver, string, object[]);
[C++] public: void InvokeMethod(ManagementOperationObserver*, String*, Object[]);
[JScript] public function InvokeMethod(ManagementOperationObserver, String, Object[]);
WMI オブジェクトのメソッドを呼び出します。入力パラメータと出力パラメータは、 ManagementBaseObject オブジェクトとして表します。
[Visual Basic] Overloads Public Function InvokeMethod(String, ManagementBaseObject, InvokeMethodOptions) As ManagementBaseObject
[C#] public ManagementBaseObject InvokeMethod(string, ManagementBaseObject, InvokeMethodOptions);
[C++] public: ManagementBaseObject* InvokeMethod(String*, ManagementBaseObject*, InvokeMethodOptions*);
オブジェクトのメソッドを非同期的に呼び出します。
[Visual Basic] Overloads Public Sub InvokeMethod(ManagementOperationObserver, String, ManagementBaseObject, InvokeMethodOptions)
使用例
[Visual Basic, C#] メモ ここでは、InvokeMethod のオーバーロード形式のうちの 1 つだけについて、使用例を示します。その他の例については、各オーバーロード形式のトピックを参照してください。
using System;
using System.Management;
// This sample demonstrates invoking a WMI method using parameter objects
public class InvokeMethod
{
public static void Main()
{
//Get the object on which the method will be invoked
ManagementClass processClass = new ManagementClass("Win32_Process");
//Get an input parameters object for this method
ManagementBaseObject inParams = processClass.GetMethodParameters("Create");
//Fill in input parameter values
inParams["CommandLine"] = "calc.exe";
//Execute the method
ManagementBaseObject outParams = processClass.InvokeMethod ("Create", inParams, null);
//Display results
//Note: The return code of the method is provided in the "returnValue" property of the outParams object
Console.WriteLine("Creation of calculator process returned: " + outParams["returnValue"]);
Console.WriteLine("Process ID: " + outParams["processId"]);
}
}
[Visual Basic]
Imports System
Imports System.Management
' This sample demonstrates invoking a WMI method using parameter objects
Class InvokeMethod
Public Overloads Shared Function Main(ByVal args() As String) As Integer
' Get the object on which the method will be invoked
Dim processClass As New ManagementClass("Win32_Process")
' Get an input parameters object for this method
Dim inParams As ManagementBaseObject = processClass.GetMethodParameters("Create")
' Fill in input parameter values
inParams("CommandLine") = "calc.exe"
' Execute the method
Dim outParams As ManagementBaseObject = processClass.InvokeMethod("Create", inParams, Nothing)
' Display results
' Note: The return code of the method is provided in the "returnValue" property of the outParams object
Console.WriteLine("Creation of calculator process returned: {0}", outParams("returnValue"))
Console.WriteLine("Process ID: {0}", outParams("processId"))
Return 0
End Function
End Class
[C++, JScript] C++ および JScript のサンプルはありません。Visual Basic および C# のサンプルを表示するには、このページの左上隅にある言語のフィルタ ボタン をクリックします。
参照
ManagementObject クラス | ManagementObject メンバ | System.Management 名前空間