Introduction
This article shows how you can get property name and method name programmatically instead of writing explicitly.
There is one special class called "meta_class" which provides schema information.
It identifies select query as schema query.
Query look like this
C#
SELECT * FROM meta_class WHERE __this ISA "Win32_LogicalDisk"Here, WMI class name declare in double quote in select query.

Code and explanation
C#
// Schema query for getting information for Win32_LogicalDisk class
ManagementObjectSearcher query = new ManagementObjectSearcher(@"SELECT * FROM meta_class WHERE __this ISA ""Win32_LogicalDisk""");
// Get each class from the select query.
foreach (ManagementClass managementClass in query.Get())
{
// Get each property name of WMI class.
foreach (PropertyData property in managementClass.Properties)
{
listBox1.Items.Add(property.Name);
}
// Get each method name of WMI class.
foreach (MethodData method in managementClass.Methods)
{
listBox2.Items.Add(method.Name);
}
}I hope you understand it.
Thanks.


Mike GoldTOP 100Posted Sep 3, 2010, 10:15 AM EDT
Thanks Hiren