InvokeMethodOptions 類別

定義

指定叫用 (Invoke) 管理方法的選項。

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 內容物件。 這是名稱值配對清單,將要傳送至 WMI 提供者 (Provider),支援自訂作業的內容資訊。

(繼承來源 ManagementOptions)
Timeout

取得或設定套用至作業的逾時。 請注意,對於傳回集合的作業來說,這個逾時會經由產生的集合套用至列舉,而不是作業本身 (ReturnImmediately 屬性會為後者使用)。 這個屬性是用來指示作業應該半同步執行。

(繼承來源 ManagementOptions)

方法

Clone()

傳回物件的複本。

Equals(Object)

判斷指定的物件是否等於目前的物件。

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。

(繼承來源 Object)
GetType()

取得目前執行個體的 Type

(繼承來源 Object)
MemberwiseClone()

建立目前 Object 的淺層複製。

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。

(繼承來源 Object)

適用於