Share via


InvokeMethodOptions クラス

定義

管理メソッドを呼び出すためのオプションを指定します。

public ref class InvokeMethodOptions : System::Management::ManagementOptions
public class InvokeMethodOptions : System.Management.ManagementOptions
type InvokeMethodOptions = class
    inherit ManagementOptions
Public Class InvokeMethodOptions
Inherits ManagementOptions
継承
InvokeMethodOptions

次の例では、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

コンストラクター

InvokeMethodOptions()

InvokeMethodOptions 操作のための InvokeMethod(String, Object[]) クラスの新しいインスタンスを、既定値を使用して初期化します。 これはパラメーターなしのコンストラクターです。

InvokeMethodOptions(ManagementNamedValueCollection, TimeSpan)

呼び出し操作のための InvokeMethodOptions クラスの新しいインスタンスを、指定した値を使用して初期化します。

プロパティ

Context

WMI (Windows Management Instrumentation) コンテキスト オブジェクトを取得または設定します。 これは、カスタマイズされた操作のためのコンテキスト情報をサポートしている WMI プロバイダーに渡す名前/値ペア リストです。

(継承元 ManagementOptions)
Timeout

操作に適用するタイムアウトを取得または設定します。 コレクションを返す操作では、このタイムアウトはその操作自体ではなく、結果として得られるコレクションの列挙に適用されます。操作自体に適用するには、ReturnImmediately プロパティを使用します。 このプロパティは、操作が半同期的に実行されることを示すために使用されます。

(継承元 ManagementOptions)

メソッド

Clone()

オブジェクトのコピーを返します。

Equals(Object)

指定されたオブジェクトが現在のオブジェクトと等しいかどうかを判断します。

(継承元 Object)
GetHashCode()

既定のハッシュ関数として機能します。

(継承元 Object)
GetType()

現在のインスタンスの Type を取得します。

(継承元 Object)
MemberwiseClone()

現在の Object の簡易コピーを作成します。

(継承元 Object)
ToString()

現在のオブジェクトを表す文字列を返します。

(継承元 Object)

適用対象