Share via


ManagementObject.InvokeMethod 메서드

정의

개체의 메서드를 호출합니다.

오버로드

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

개체의 메서드를 호출합니다.

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

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

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

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

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

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 보안

직접 실행 호출자의 경우 완전히 신뢰합니다. 이 멤버는 부분적으로 신뢰할 수 있는 코드에서 사용할 수 없습니다. 자세한 내용은 부분적으로 신뢰할 수 있는 코드에서 라이브러리를 사용 하 여입니다.

적용 대상