Initialize a ManagementClass and Get the properties in the class : ManagementClass « Windows « C# / C Sharp






Initialize a ManagementClass and Get the properties in the class

  


using System;
using System.Management;

public class Sample 
{    
    public static void Main() 
    {

        // Get the WMI class
        ManagementClass c = new ManagementClass("Win32_LogicalDisk");

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

        // Get the properties in the class
        PropertyDataCollection properties = c.Properties;

        // display the properties
        Console.WriteLine("Property Names: ");
        foreach (PropertyData property in properties)
        {
            Console.WriteLine(property.Name);
        }

    }
}

   
    
  








Related examples in the same category

1.Enumerate ManagementClass
2.Initialize a ManagementClass and list its methods
3.Initialize a ManagementClass and Get the Qualifiers in the class
4.Create ManagementObjectSearcher to query Win32_Service