ManagementObject.InvokeMethod メソッド
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
オブジェクトのメソッドを呼び出します。
オーバーロード
| 名前 | 説明 |
|---|---|
| InvokeMethod(String, Object[]) |
オブジェクトのメソッドを呼び出します。 |
| InvokeMethod(ManagementOperationObserver, String, Object[]) |
オブジェクトのメソッドを非同期的に呼び出します。 |
| InvokeMethod(String, ManagementBaseObject, InvokeMethodOptions) |
WMI オブジェクトのメソッドを呼び出します。 入力パラメーターと出力パラメーターは、 ManagementBaseObject オブジェクトとして表されます。 |
| InvokeMethod(ManagementOperationObserver, String, ManagementBaseObject, InvokeMethodOptions) |
オブジェクトのメソッドを非同期的に呼び出します。 |
InvokeMethod(String, Object[])
オブジェクトのメソッドを呼び出します。
public:
System::Object ^ InvokeMethod(System::String ^ methodName, cli::array <System::Object ^> ^ args);
public object InvokeMethod(string methodName, object[] args);
member this.InvokeMethod : string * obj[] -> obj
Public Function InvokeMethod (methodName As String, args As Object()) As Object
パラメーター
- methodName
- String
実行するメソッドの名前。
- args
- Object[]
パラメーター値を含む配列。
返品
メソッドによって返されるオブジェクト値。
例
次の例では 、Win32_Process::Create メソッドを呼び出して、Notepad.exeの新しいプロセスを開始します。
using System;
using System.Management;
// This sample demonstrates invoking
// a WMI method using an array of arguments.
public class InvokeMethod
{
public static void Main()
{
// Get the object on which the
// method will be invoked
ManagementClass processClass =
new ManagementClass("Win32_Process");
// Create an array containing all
// arguments for the method
object[] methodArgs =
{"notepad.exe", null, null, 0};
//Execute the method
object result =
processClass.InvokeMethod(
"Create", methodArgs);
//Display results
Console.WriteLine(
"Creation of process returned: " + result);
Console.WriteLine("Process id: " + methodArgs[3]);
}
}
Imports System.Management
' This sample demonstrates invoking a WMI method
' using an array of arguments.
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")
' Create an array containing all arguments
' for the method
Dim methodArgs() As Object = _
{"notepad.exe", Nothing, Nothing, 0}
' Execute the method
Dim result As Object = _
processClass.InvokeMethod("Create", methodArgs)
' Display results
Console.WriteLine( _
"Creation of process returned: {0}", result)
Console.WriteLine( _
"Process id: {0}", methodArgs(3))
Return 0
End Function
End Class
注釈
メソッドが静的な場合でも、実行は成功するはずです。
.NET Framework のセキュリティ
直接呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されたコードでは使用できません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。
適用対象
InvokeMethod(ManagementOperationObserver, String, Object[])
オブジェクトのメソッドを非同期的に呼び出します。
public:
void InvokeMethod(System::Management::ManagementOperationObserver ^ watcher, System::String ^ methodName, cli::array <System::Object ^> ^ args);
public void InvokeMethod(System.Management.ManagementOperationObserver watcher, string methodName, object[] args);
member this.InvokeMethod : System.Management.ManagementOperationObserver * string * obj[] -> unit
Public Sub InvokeMethod (watcher As ManagementOperationObserver, methodName As String, args As Object())
パラメーター
- watcher
- ManagementOperationObserver
操作の結果を受け取るオブジェクト。
- methodName
- String
実行するメソッドの名前。
- args
- Object[]
パラメーター値を含む配列。
注釈
メソッドが静的な場合でも、実行は成功するはずです。
.NET Framework のセキュリティ
直接呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されたコードでは使用できません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。
適用対象
InvokeMethod(String, ManagementBaseObject, InvokeMethodOptions)
WMI オブジェクトのメソッドを呼び出します。 入力パラメーターと出力パラメーターは、 ManagementBaseObject オブジェクトとして表されます。
public:
System::Management::ManagementBaseObject ^ InvokeMethod(System::String ^ methodName, System::Management::ManagementBaseObject ^ inParameters, System::Management::InvokeMethodOptions ^ options);
public System.Management.ManagementBaseObject InvokeMethod(string methodName, System.Management.ManagementBaseObject inParameters, System.Management.InvokeMethodOptions options);
member this.InvokeMethod : string * System.Management.ManagementBaseObject * System.Management.InvokeMethodOptions -> System.Management.ManagementBaseObject
Public Function InvokeMethod (methodName As String, inParameters As ManagementBaseObject, options As InvokeMethodOptions) As ManagementBaseObject
パラメーター
- methodName
- String
実行するメソッドの名前。
- inParameters
- ManagementBaseObject
メソッドへの入力パラメーターを保持する ManagementBaseObject 。
- options
- InvokeMethodOptions
メソッドを実行するための追加のオプションを含む InvokeMethodOptions 。
返品
実行されたメソッドの出力パラメーターと戻り値を含む ManagementBaseObject 。
例
次の例では 、Win32_Process::Create メソッドを呼び出して、Calc.exeの新しいプロセスを開始します。
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"]);
}
}
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
注釈
.NET Framework のセキュリティ
直接呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されたコードでは使用できません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。
適用対象
InvokeMethod(ManagementOperationObserver, String, ManagementBaseObject, InvokeMethodOptions)
オブジェクトのメソッドを非同期的に呼び出します。
public:
void InvokeMethod(System::Management::ManagementOperationObserver ^ watcher, System::String ^ methodName, System::Management::ManagementBaseObject ^ inParameters, System::Management::InvokeMethodOptions ^ options);
public void InvokeMethod(System.Management.ManagementOperationObserver watcher, string methodName, System.Management.ManagementBaseObject inParameters, System.Management.InvokeMethodOptions options);
member this.InvokeMethod : System.Management.ManagementOperationObserver * string * System.Management.ManagementBaseObject * System.Management.InvokeMethodOptions -> unit
Public Sub InvokeMethod (watcher As ManagementOperationObserver, methodName As String, inParameters As ManagementBaseObject, options As InvokeMethodOptions)
パラメーター
- watcher
- ManagementOperationObserver
非同期実行の進行状況と結果を処理するために使用される ManagementOperationObserver 。
- methodName
- String
実行するメソッドの名前。
- inParameters
- ManagementBaseObject
メソッドの入力パラメーターを含む ManagementBaseObject 。
- options
- InvokeMethodOptions
メソッドの実行に使用される追加のオプションを含む InvokeMethodOptions 。
注釈
このメソッドは、指定されたメソッドの実行を呼び出し、返します。 進行状況と結果は、 ManagementOperationObserverのイベントを通じて報告されます。
.NET Framework のセキュリティ
直接呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されたコードでは使用できません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。