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: SELECT * FROM meta_class WHERE __this ISA "Win32_LogicalDisk" Here, WMI class name declare in double quote in select query. Figure1: Code and explanation: // Schema query for getting infomation for Win32_LogicalDisk class ManagementObjectSearcher q = new ManagementObjectSearcher(@"SELECT * FROM meta_class WHERE __this ISA ""Win32_LogicalDisk""");
// get the each class from the select query. foreach (ManagementClass c in q.Get()) { // get the each propery name of WMI class foreach (PropertyData d in c.Properties) { listBox1.Items.Add(d.Name); }
// get the each method name of WMI class foreach (MethodData m in c.Methods) {
listBox2.Items.Add(m.Name);
} } Hope you understand it, Thanks.
You need to be a premium member to use this feature. To access it, you'll have to upgrade your membership.
Become a sharper developer and jumpstart your career.
$0
$
. 00
monthly
For Basic members:
$20
For Premium members:
$45
For Elite members: