InvokeMethodOptions コンストラクター
定義
重要
一部の情報は、リリース前に大きく変更される可能性があるプレリリースされた製品に関するものです。 Microsoft は、ここに記載されている情報について、明示または黙示を問わず、一切保証しません。
呼び出し操作の InvokeMethodOptions クラスの新しいインスタンスを初期化します。
オーバーロード
| 名前 | 説明 |
|---|---|
| InvokeMethodOptions() |
既定値を使用して、InvokeMethodOptions操作のInvokeMethod(String, Object[]) クラスの新しいインスタンスを初期化します。 これはパラメーターなしのコンストラクターです。 |
| InvokeMethodOptions(ManagementNamedValueCollection, TimeSpan) |
指定した値を使用して、呼び出し操作の InvokeMethodOptions クラスの新しいインスタンスを初期化します。 |
InvokeMethodOptions()
既定値を使用して、InvokeMethodOptions操作のInvokeMethod(String, Object[]) クラスの新しいインスタンスを初期化します。 これはパラメーターなしのコンストラクターです。
public:
InvokeMethodOptions();
public InvokeMethodOptions();
Public Sub New ()
例
次の例では 、Win32_Process::Create メソッドを呼び出して、Calc.exeの新しいプロセスを開始します。 InvokeMethodOptions クラスのパラメーターなしのコンストラクターが使用されます。
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";
// Method Options
InvokeMethodOptions methodOptions = new
InvokeMethodOptions();
methodOptions.Timeout =
System.TimeSpan.MaxValue;
// Execute the method
ManagementBaseObject outParams =
processClass.InvokeMethod("Create",
inParams, methodOptions);
// 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("root\CIMV2", _
"Win32_Process", _
Nothing)
' Get an input parameters object for this method
Dim inParams As ManagementBaseObject = _
processClass.GetMethodParameters("Create")
' Fill in input parameter values
inParams("CommandLine") = "calc.exe"
' Method Options
Dim methodOptions As New InvokeMethodOptions
methodOptions.Timeout = _
System.TimeSpan.MaxValue
' Execute the method
Dim outParams As ManagementBaseObject = _
processClass.InvokeMethod( _
"Create", inParams, methodOptions)
' 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 のセキュリティ
直接呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されたコードでは使用できません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。
適用対象
InvokeMethodOptions(ManagementNamedValueCollection, TimeSpan)
指定した値を使用して、呼び出し操作の InvokeMethodOptions クラスの新しいインスタンスを初期化します。
public:
InvokeMethodOptions(System::Management::ManagementNamedValueCollection ^ context, TimeSpan timeout);
public InvokeMethodOptions(System.Management.ManagementNamedValueCollection context, TimeSpan timeout);
new System.Management.InvokeMethodOptions : System.Management.ManagementNamedValueCollection * TimeSpan -> System.Management.InvokeMethodOptions
Public Sub New (context As ManagementNamedValueCollection, timeout As TimeSpan)
パラメーター
- context
- ManagementNamedValueCollection
プロバイダーに渡されるプロバイダー固有の名前付き値ペア オブジェクト。
- timeout
- TimeSpan
タイムアウトするまでの操作の実行時間。既定値は TimeSpan.MaxValue です。 このパラメーターを設定すると、操作が半同期的に呼び出されます。
例
次の例では 、Win32_Process::Create メソッドを呼び出して、Calc.exeの新しいプロセスを開始します。 InvokeMethodOptions クラスは、メソッドの呼び出しに使用されます。
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";
// Method Options
InvokeMethodOptions methodOptions = new
InvokeMethodOptions(null,
System.TimeSpan.MaxValue);
// Execute the method
ManagementBaseObject outParams =
processClass.InvokeMethod("Create",
inParams, methodOptions);
// 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("root\CIMV2", _
"Win32_Process", _
Nothing)
' Get an input parameters object for this method
Dim inParams As ManagementBaseObject = _
processClass.GetMethodParameters("Create")
' Fill in input parameter values
inParams("CommandLine") = "calc.exe"
' Method Options
Dim methodOptions As New InvokeMethodOptions( _
Nothing, System.TimeSpan.MaxValue)
' Execute the method
Dim outParams As ManagementBaseObject = _
processClass.InvokeMethod( _
"Create", inParams, methodOptions)
' 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 のセキュリティ
直接呼び出し元に対する完全な信頼。 このメンバーは、部分的に信頼されたコードでは使用できません。 詳細については、「 部分信頼コードからのライブラリの使用」を参照してください。