Get Property and Method Name of WMI Classes Programmatically in C#
Here i will explain you , how you can get property name and method name of WMI classes programmatically instead of writing explicitly.
Information about WMI classes and how to use it:
you can see this article of peter bromberg.
Retrieving Hardware Identifiers in C# with WMI
There is one special class called "meta_class" which provides schema information
of WMI classes.
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.
Code and explanation:
// Schema query for getting infomation for Win32_LogicalDisk class
var 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)
// get the each method name of WMI class
foreach (MethodData m in c.Methods)
By Super Man Popularity (1592 Views)