This documentation is archived and is not being maintained.

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.

.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 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

Supported in: 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows XP SP2 x64 Edition, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.