SelectQuery Constructor (String, String)


Initializes a new instance of the SelectQuery class with the specified class name and condition.

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

public SelectQuery(
	string className,
	string condition


Type: System.String

The name of the class to select in the query.

Type: System.String

The condition to be applied in the query.

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 and a condition.

using System;
using System.Management;

public class Sample 
    public static void Main(string[] args) 
        SelectQuery s = 
            new SelectQuery("Win32_Service",
            "State = 'Stopped'");

        ManagementObjectSearcher searcher = 
            new ManagementObjectSearcher(

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

.NET Framework
Available since 1.1
Return to top