MethodData 类

定义

包含关于 WMI 方法的信息。Contains information about a WMI method.

public ref class MethodData
public class MethodData
type MethodData = class
Public Class MethodData
继承
MethodData

示例

下面的示例使用MethodData类列出有关Win32_Process方法的信息。The following example lists information about the Win32_Process.Create method using the MethodData class. 有关Win32_Process类的详细信息, 请参阅Windows Management Instrumentation文档。For more information on the Win32_Process class, see the Windows Management Instrumentation documentation.

using System;
using System.Management;

public class Sample 
{    
    public static void Main() 
    {

        // Get the WMI class
        ManagementClass processClass = 
            new ManagementClass("Win32_Process");
        processClass.Options.UseAmendedQualifiers = true;

        // Get the methods in the class
        MethodDataCollection methods =
            processClass.Methods;

        // display the method names
        Console.WriteLine("Method Name: ");
        foreach (MethodData method in methods)
        {
            if(method.Name.Equals("Create"))
            {
                Console.WriteLine(method.Name);
                Console.WriteLine("Description: " +
                    method.Qualifiers["Description"].Value);
                Console.WriteLine();

                Console.WriteLine("In-parameters: ");
                foreach(PropertyData i in 
                    method.InParameters.Properties)
                {
                    Console.WriteLine(i.Name);
                }
                Console.WriteLine();

                Console.WriteLine("Out-parameters: ");
                foreach(PropertyData o in 
                    method.OutParameters.Properties)
                {
                    Console.WriteLine(o.Name);
                }
                Console.WriteLine();

                Console.WriteLine("Qualifiers: ");
                foreach(QualifierData q in 
                    method.Qualifiers)
                {
                    Console.WriteLine(q.Name);
                }
                Console.WriteLine();
            }
        } 
    }
}
Imports System.Management


Public Class Sample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Get the WMI class
        Dim processClass As ManagementClass = _
            New ManagementClass("Win32_Process")
        processClass.Options.UseAmendedQualifiers = True

        ' Get the methods in the class
        Dim methods As MethodDataCollection = _
            processClass.Methods

        ' display the method names
        Console.WriteLine("Method Name: ")
        For Each method As MethodData In methods

            If (method.Name.Equals("Create")) Then

                Console.WriteLine(method.Name)
                Console.WriteLine("Description: " & _
                    method.Qualifiers("Description").Value)
                Console.WriteLine()

                Console.WriteLine("In-parameters: ")
                For Each i As PropertyData In _
                    method.InParameters.Properties

                    Console.WriteLine(i.Name)
                Next
                Console.WriteLine()

                Console.WriteLine("Out-parameters: ")
                For Each o As PropertyData In _
                    method.OutParameters.Properties

                    Console.WriteLine(o.Name)
                Next
                Console.WriteLine()

                Console.WriteLine("Qualifiers: ")
                For Each q As QualifierData In _
                    method.Qualifiers

                    Console.WriteLine(q.Name)
                Next
                Console.WriteLine()

            End If
        Next

    End Function 'Main
End Class

属性

InParameters

获取方法的输入参数。Gets the input parameters to the method. 将每个参数都描述为对象的一个属性。Each parameter is described as a property in the object. 如果一个参数既是输入参数又是输出参数,则该参数将同时出现在 InParametersOutParameters 属性中。If a parameter is both in and out, it appears in both the InParameters and OutParameters properties.

Name

获取方法的名称。Gets the name of the method.

Origin

获取管理类的名称,在该类中第一次将该方法引入到类的继承层次结构。Gets the name of the management class in which the method was first introduced in the class inheritance hierarchy.

OutParameters

获取方法的输出参数。Gets the output parameters to the method. 将每个参数都描述为对象的一个属性。Each parameter is described as a property in the object. 如果一个参数既是输入参数又是输出参数,则该参数将同时出现在 InParametersOutParameters 属性中。If a parameter is both in and out, it will appear in both the InParameters and OutParameters properties.

Qualifiers

获取在方法中定义的限定符集合。Gets a collection of qualifiers defined in the method. 每个元素都是 QualifierData 类型,并包含诸如限定符名称、值和风格之类的信息。Each element is of type QualifierData and contains information such as the qualifier name, value, and flavor.

方法

Equals(Object)

确定指定的对象是否等于当前对象。Determines whether the specified object is equal to the current object.

(继承自 Object)
GetHashCode()

用作默认哈希函数。Serves as the default hash function.

(继承自 Object)
GetType()

获取当前实例的 TypeGets the Type of the current instance.

(继承自 Object)
MemberwiseClone()

创建当前 Object 的浅表副本。Creates a shallow copy of the current Object.

(继承自 Object)
ToString()

返回一个表示当前对象的 string。Returns a string that represents the current object.

(继承自 Object)

适用于