Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

MethodData Class

Contains information about a WMI method.

For a list of all members of this type, see MethodData Members.

System.Object
   System.Management.MethodData

[Visual Basic]
Public Class MethodData
[C#]
public class MethodData
[C++]
public __gc class MethodData
[JScript]
public class MethodData

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

Example

[C#] 
using System; 
using System.Management; 

// This example shows how to obtain meta data 
// about a WMI method with a given name in a given WMI class 

class Sample_MethodData 
{ 
    public static int Main(string[] args) { 

        // Get the "SetPowerState" method in the Win32_LogicalDisk class 
        ManagementClass diskClass = new ManagementClass("win32_logicaldisk");
        MethodData m = diskClass.Methods["SetPowerState"];
      
        // Get method name (albeit we already know it)
        Console.WriteLine("Name: " + m.Name);

        // Get the name of the top-most class where this specific method was defined
        Console.WriteLine("Origin: " + m.Origin);
      
        // List names and types of input parameters
        ManagementBaseObject inParams = m.InParameters;
        foreach(PropertyData pdata in inParams.Properties) {
            Console.WriteLine();
            Console.WriteLine("InParam_Name: " + pdata.Name);
            Console.WriteLine("InParam_Type: " + pdata.Type);
        }
      
        // List names and types of output parameters
        ManagementBaseObject outParams = m.OutParameters;
        foreach(PropertyData pdata in outParams.Properties) {
            Console.WriteLine();
            Console.WriteLine("OutParam_Name: " + pdata.Name);
            Console.WriteLine("OutParam_Type: " + pdata.Type);
        }
      
        return 0;
    }
}
   
[Visual Basic] 
Imports System
Imports System.Management
      
' This example shows how to obtain meta data 
' about a WMI method with a given name in a given WMI class 

Class Sample_ManagementClass
    Overloads Public Shared Function Main(args() As String) As Integer
        
        ' Get the "SetPowerState" method in the Win32_LogicalDisk class 
        Dim diskClass As New ManagementClass("Win32_LogicalDisk")
        Dim m As MethodData = diskClass.Methods("SetPowerState")
      
        ' Get method name (albeit we already know it)
        Console.WriteLine("Name: " & m.Name)
        
        ' Get the name of the top-most class where
        ' this specific method was defined
        Console.WriteLine("Origin: " & m.Origin)

        ' List names and types of input parameters
        Dim inParams As ManagementBaseObject 
        inParams = m.InParameters
        Dim pdata As PropertyData
        For Each pdata In inParams.Properties
            Console.WriteLine()
            Console.WriteLine("InParam_Name: " & pdata.Name)
            Console.WriteLine("InParam_Type: " & pdata.Type)
        Next pdata

        ' List names and types of output parameters
        Dim outParams As ManagementBaseObject 
        outParams = m.OutParameters
        For Each pdata in outParams.Properties
            Console.WriteLine()
            Console.WriteLine("OutParam_Name: " & pdata.Name)
            Console.WriteLine("OutParam_Type: " & pdata.Type)
        Next pdata
     
        Return 0
    End Function
End Class
   

[C++, JScript] No example is available for C++ or JScript. To view a Visual Basic or C# example, click the Language Filter button Language Filter in the upper-left corner of the page.

Requirements

Namespace: System.Management

Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family

Assembly: System.Management (in System.Management.dll)

See Also

MethodData Members | System.Management Namespace

Show:
© 2015 Microsoft