Skip to content

Latest commit

 

History

History
56 lines (40 loc) · 1.02 KB

README.md

File metadata and controls

56 lines (40 loc) · 1.02 KB

BytecodeApi.Wmi

Library for efficient WMI querying.

Examples

BytecodeApi.Wmi

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

Changelog

3.0.0 (08.09.2023)

  • Initial release