ManagementObject.InvokeMethod 메서드

정의

개체에 대한 메서드를 호출합니다.

오버로드

Name Description
InvokeMethod(String, Object[])

개체에 대한 메서드를 호출합니다.

InvokeMethod(ManagementOperationObserver, String, Object[])

개체에서 메서드를 비동기적으로 호출합니다.

InvokeMethod(String, ManagementBaseObject, InvokeMethodOptions)

WMI 개체에서 메서드를 호출합니다. 입력 및 출력 매개 변수는 개체로 ManagementBaseObject 표시됩니다.

InvokeMethod(ManagementOperationObserver, String, ManagementBaseObject, InvokeMethodOptions)

개체에서 메서드를 비동기적으로 호출합니다.

InvokeMethod(String, Object[])

Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs

개체에 대한 메서드를 호출합니다.

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[])

Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs

개체에서 메서드를 비동기적으로 호출합니다.

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)

Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs

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)

Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs
Source:
ManagementObject.cs

개체에서 메서드를 비동기적으로 호출합니다.

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 메서드에 대한 입력 매개 변수를 포함하는 A.

options
InvokeMethodOptions

InvokeMethodOptions 메서드를 실행하는 데 사용되는 추가 옵션이 포함되어 있습니다.

설명

메서드는 지정된 메서드 실행을 호출한 다음 반환합니다. 진행률 및 결과는 에 대한 ManagementOperationObserver이벤트를 통해 보고됩니다.

.NET Framework 보안

즉시 호출자에 대한 완전 신뢰입니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분적으로 신뢰할 수 있는 코드의 라이브러리 사용을 참조하세요.

적용 대상