Mega Code Archive

 
Categories / C# / Windows
 

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);         }     } }