Queries

With WMI, the consumer can precisely define the data stream using queries. Queries limit the amount of data being returned both by specifying only those properties of interest (in the SELECT statement) and by retrieving only the entities of interest (using the WHERE clause). For example, if a user wanted to query on all drives on a computer (drive C, D, and so on) that fell below 2 MB:

SELECT * FROM Win32_LogicalDisk WHERE FreeSpace < 2000000

While the use of queries is not exactly new, queries represent a radical departure from the normal management API in which the only interface available supported the enumeration of elements of a particular type, with little or no opportunity to filter them.

See Also

Using WMI with the .NET Framework | Schemas | Using Management Events | Instrumenting .NET Framework Applications with System.Management