Export (0) Print
Expand All

SelectQuery Constructor (String, String, String[])

Initializes a new instance of the SelectQuery class with the specified class name and condition, selecting only the specified properties.

Namespace:  System.Management
Assembly:  System.Management (in System.Management.dll)

public SelectQuery(
	string className,
	string condition,
	string[] selectedProperties


Type: System.String

The name of the class from which to select.

Type: System.String

The condition to be applied to instances of the selected class.

Type: System.String[]

An array of property names to be returned in the query results.

.NET Framework Security

Full trust for the immediate caller. This member cannot be used by partially trusted code. For more information, see Using Libraries from Partially Trusted Code.

The following example initializes a SelectQuery by specifying a WMI class name, condition, and array of properties.

using System;
using System.Management;

public class Sample 
    public static void Main(string[] args) 
        String[] properties = 
            {"Name", "Handle"};

        SelectQuery s = new SelectQuery("Win32_Process",
            "Name = 'notepad.exe'", 

        ManagementObjectSearcher searcher = 
            new ManagementObjectSearcher(

        foreach (ManagementObject o in searcher.Get()) 
            // show the class

.NET Framework

Supported in: 4.6, 4.5, 4, 3.5, 3.0, 2.0, 1.1

.NET Framework Client Profile

Supported in: 4, 3.5 SP1
© 2015 Microsoft