Reflect on a WMI Class

Problem

You want to use reflection to retrieve information about a Windows Management Instrumentation (WMI) class.

Solution

Create a ManagementClass object for the WMI class, and then explore it using properties such as ManagementClass.Methods, ManagementClass.Properties, MethodData.InParameters, and MethodData.OutParameters.

Discussion

Windows Management Instrumentation is a core component of the Windows operating system that allows your code to retrieve a vast amount of system and hardware information using a query-like syntax. The basic unit of WMI is the WMI class, which is similar to a .NET class, exposing properties and methods. However, you can’t use a WMI class directly from .NET code; instead, you access a WMI class ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.