Library for efficient WMI querying.
Retrieve list of WMI objects by reading entire table:
WmiObject[] processes = WmiContext.Root
.GetNamespace("CIMV2")
.GetClass("Win32_Process")
.ToArray();
foreach (WmiObject process in processes)
{
// Retrieve properties for each WmiObject
Console.WriteLine(process.Properties["Name"].Value);
Console.WriteLine(process.Properties["CommandLine"].Value);
}
Retrieve one WMI object:
WmiObject? process = WmiContext.Root
.GetNamespace("CIMV2")
.GetClass("Win32_Process")
.Where("ProcessId = 4")
.FirstOrDefault();
string? caption = process?.Properties["Caption"].GetValue<string>();
Retrieve all classes from a namespace:
WmiClass[] classes = WmiContext.Root
.GetNamespace("CIMV2")
.GetClasses();
Retrieve all namespaces from a namespace:
WmiNamespace[] namespaces = WmiContext.Root
.GetNamespaces();
- Initial release