WqlEventQuery Constructor (String)


Initializes a new instance of the WqlEventQuery class based on the given query string or event class name.

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

public WqlEventQuery(
	string queryOrEventClassName


Type: System.String

The string representing either the entire event query or the name of the event class to query. The object will try to parse the string as a valid event query. If unsuccessful, the parser will assume that the parameter represents an event class name.

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 WqlEventQuery by specifying a query and then initializes a WqlEventQuery by specifying an event.

using System;
using System.Management;

public class EventSample 
    public static void Main(string[] args) 
        // Full query string specified to the constructor
        WqlEventQuery q = 
            new WqlEventQuery("SELECT * FROM Win32_ComputerShutdownEvent");

        // Only relevant event class name specified to the constructor   
        // Results in the same query as above.
        WqlEventQuery query =
            new WqlEventQuery("Win32_ComputerShutdownEvent ");


.NET Framework
Available since 1.1
Return to top