Muokkaa

Jaa


WqlEventQuery Constructors

Definition

Initializes a new instance of the WqlEventQuery class.

Overloads

WqlEventQuery()

Initializes a new instance of the WqlEventQuery class. This is the parameterless constructor.

WqlEventQuery(String)

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

WqlEventQuery(String, String)

Initializes a new instance of the WqlEventQuery class for the specified event class name, with the specified condition.

WqlEventQuery(String, TimeSpan)

Initializes a new instance of the WqlEventQuery class for the specified event class, with the specified latency time.

WqlEventQuery(String, String, TimeSpan)

Initializes a new instance of the WqlEventQuery class with the specified event class name, condition, and grouping interval.

WqlEventQuery(String, TimeSpan, String)

Initializes a new instance of the WqlEventQuery class with the specified event class name, polling interval, and condition.

WqlEventQuery(String, String, TimeSpan, String[])

Initializes a new instance of the WqlEventQuery class with the specified event class name, condition, grouping interval, and grouping properties.

WqlEventQuery(String, TimeSpan, String, TimeSpan, String[], String)

Initializes a new instance of the WqlEventQuery class with the specified event class name, condition, grouping interval, grouping properties, and specified number of events.

WqlEventQuery()

Source:
ManagementQuery.cs
Source:
ManagementQuery.cs
Source:
ManagementQuery.cs

Initializes a new instance of the WqlEventQuery class. This is the parameterless constructor.

public:
 WqlEventQuery();
public WqlEventQuery ();
Public Sub New ()

Remarks

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

Applies to

WqlEventQuery(String)

Source:
ManagementQuery.cs
Source:
ManagementQuery.cs
Source:
ManagementQuery.cs

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

public:
 WqlEventQuery(System::String ^ queryOrEventClassName);
public WqlEventQuery (string queryOrEventClassName);
new System.Management.WqlEventQuery : string -> System.Management.WqlEventQuery
Public Sub New (queryOrEventClassName As String)

Parameters

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

Examples

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 ");

        Console.WriteLine(query.QueryString);
        return;
    }
}
Imports System.Management


Public Class EventSample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        '' Full query string specified to the constructor
        Dim q As New WqlEventQuery( _
            "SELECT * FROM Win32_ComputerShutdownEvent ")

        ' Only relevant event class name specified to the constructor
        ' Results in the same query as above   
        Dim query As New WqlEventQuery("Win32_ComputerShutdownEvent ")

        MessageBox.Show(query.QueryString)

    End Function 'Main
End Class

Remarks

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

Applies to

WqlEventQuery(String, String)

Source:
ManagementQuery.cs
Source:
ManagementQuery.cs
Source:
ManagementQuery.cs

Initializes a new instance of the WqlEventQuery class for the specified event class name, with the specified condition.

public:
 WqlEventQuery(System::String ^ eventClassName, System::String ^ condition);
public WqlEventQuery (string eventClassName, string condition);
new System.Management.WqlEventQuery : string * string -> System.Management.WqlEventQuery
Public Sub New (eventClassName As String, condition As String)

Parameters

eventClassName
String

The name of the event class to query.

condition
String

The condition to apply to events of the specified class.

Remarks

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

Applies to

WqlEventQuery(String, TimeSpan)

Source:
ManagementQuery.cs
Source:
ManagementQuery.cs
Source:
ManagementQuery.cs

Initializes a new instance of the WqlEventQuery class for the specified event class, with the specified latency time.

public:
 WqlEventQuery(System::String ^ eventClassName, TimeSpan withinInterval);
public WqlEventQuery (string eventClassName, TimeSpan withinInterval);
new System.Management.WqlEventQuery : string * TimeSpan -> System.Management.WqlEventQuery
Public Sub New (eventClassName As String, withinInterval As TimeSpan)

Parameters

eventClassName
String

The name of the event class to query.

withinInterval
TimeSpan

A TimeSpan value specifying the latency acceptable for receiving this event. This value is used in cases where there is no explicit event provider for the query requested, and WMI is required to poll for the condition. This interval is the maximum amount of time that can pass before notification of an event must be delivered.

Examples

The following example initializes a WqlEventQuery by specifying an event and a time span value specifying the latency acceptable for receiving this event.

using System;
using System.Management;

public class EventSample
{
    public static void Main(string[] args)
    {
        // Requests all instance creation events,
        // with a specified latency of
        // 10 seconds. The query created
        // is "SELECT * FROM __InstanceCreationEvent WITHIN 10"
        WqlEventQuery q = new WqlEventQuery("__InstanceCreationEvent",
            new TimeSpan(0,0,10));

        Console.WriteLine(q.QueryString);
        return;
    }
}
Imports System.Management


Public Class EventSample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Requests all instance creation events,
        ' with a specified latency of
        ' 10 seconds. The query created
        ' is "SELECT * FROM __InstanceCreationEvent WITHIN 10"
        Dim t As New TimeSpan(0, 0, 10)
        Dim q As New WqlEventQuery("__InstanceCreationEvent", t)

        MessageBox.Show(q.QueryString)

    End Function 'Main
End Class

Remarks

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

Applies to

WqlEventQuery(String, String, TimeSpan)

Source:
ManagementQuery.cs
Source:
ManagementQuery.cs
Source:
ManagementQuery.cs

Initializes a new instance of the WqlEventQuery class with the specified event class name, condition, and grouping interval.

public:
 WqlEventQuery(System::String ^ eventClassName, System::String ^ condition, TimeSpan groupWithinInterval);
public WqlEventQuery (string eventClassName, string condition, TimeSpan groupWithinInterval);
new System.Management.WqlEventQuery : string * string * TimeSpan -> System.Management.WqlEventQuery
Public Sub New (eventClassName As String, condition As String, groupWithinInterval As TimeSpan)

Parameters

eventClassName
String

The name of the event class to query.

condition
String

The condition to apply to events of the specified class.

groupWithinInterval
TimeSpan

The specified interval at which WMI sends one aggregate event, rather than many events.

Remarks

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

Applies to

WqlEventQuery(String, TimeSpan, String)

Source:
ManagementQuery.cs
Source:
ManagementQuery.cs
Source:
ManagementQuery.cs

Initializes a new instance of the WqlEventQuery class with the specified event class name, polling interval, and condition.

public:
 WqlEventQuery(System::String ^ eventClassName, TimeSpan withinInterval, System::String ^ condition);
public WqlEventQuery (string eventClassName, TimeSpan withinInterval, string condition);
new System.Management.WqlEventQuery : string * TimeSpan * string -> System.Management.WqlEventQuery
Public Sub New (eventClassName As String, withinInterval As TimeSpan, condition As String)

Parameters

eventClassName
String

The name of the event class to query.

withinInterval
TimeSpan

A TimeSpan value specifying the latency acceptable for receiving this event. This value is used in cases where there is no explicit event provider for the query requested and WMI is required to poll for the condition. This interval is the maximum amount of time that can pass before notification of an event must be delivered.

condition
String

The condition to apply to events of the specified class.

Examples

The following example creates the event query: "SELECT * FROM __InstanceCreationEvent WITHIN 10 WHERE TargetInstance ISA Win32_Service ", which sends notification of the creation of Win32_Service instances, with a 10-second polling interval.

using System;
using System.Management;

public class EventSample
{
    public static void Main(string[] args)
    {
        // Requests notification of the creation
        // of Win32_Service instances with
        // a 10 second allowed latency.
        WqlEventQuery q = new WqlEventQuery("__InstanceCreationEvent",
            new TimeSpan(0,0,10),
            "TargetInstance isa 'Win32_Service'");

        Console.WriteLine(q.QueryString);
        return;
    }
}
Imports System.Management


Public Class EventSample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Requests notification of the creation
        ' of Win32_Service instances with a 10 second
        ' allowed latency.
        Dim t As New TimeSpan(0, 0, 10)
        Dim q As New WqlEventQuery("__InstanceCreationEvent", _
            t, "TargetInstance isa ""Win32_Service""")

        MessageBox.Show(q.QueryString)

    End Function 'Main
End Class

Remarks

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

Applies to

WqlEventQuery(String, String, TimeSpan, String[])

Source:
ManagementQuery.cs
Source:
ManagementQuery.cs
Source:
ManagementQuery.cs

Initializes a new instance of the WqlEventQuery class with the specified event class name, condition, grouping interval, and grouping properties.

public:
 WqlEventQuery(System::String ^ eventClassName, System::String ^ condition, TimeSpan groupWithinInterval, cli::array <System::String ^> ^ groupByPropertyList);
public WqlEventQuery (string eventClassName, string condition, TimeSpan groupWithinInterval, string[] groupByPropertyList);
new System.Management.WqlEventQuery : string * string * TimeSpan * string[] -> System.Management.WqlEventQuery
Public Sub New (eventClassName As String, condition As String, groupWithinInterval As TimeSpan, groupByPropertyList As String())

Parameters

eventClassName
String

The name of the event class to query.

condition
String

The condition to apply to events of the specified class.

groupWithinInterval
TimeSpan

The specified interval at which WMI sends one aggregate event, rather than many events.

groupByPropertyList
String[]

The properties in the event class by which the events should be grouped.

Remarks

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

Applies to

WqlEventQuery(String, TimeSpan, String, TimeSpan, String[], String)

Source:
ManagementQuery.cs
Source:
ManagementQuery.cs
Source:
ManagementQuery.cs

Initializes a new instance of the WqlEventQuery class with the specified event class name, condition, grouping interval, grouping properties, and specified number of events.

public:
 WqlEventQuery(System::String ^ eventClassName, TimeSpan withinInterval, System::String ^ condition, TimeSpan groupWithinInterval, cli::array <System::String ^> ^ groupByPropertyList, System::String ^ havingCondition);
public WqlEventQuery (string eventClassName, TimeSpan withinInterval, string condition, TimeSpan groupWithinInterval, string[] groupByPropertyList, string havingCondition);
new System.Management.WqlEventQuery : string * TimeSpan * string * TimeSpan * string[] * string -> System.Management.WqlEventQuery
Public Sub New (eventClassName As String, withinInterval As TimeSpan, condition As String, groupWithinInterval As TimeSpan, groupByPropertyList As String(), havingCondition As String)

Parameters

eventClassName
String

The name of the event class on which to be queried.

withinInterval
TimeSpan

A TimeSpan value specifying the latency acceptable for receiving this event. This value is used in cases where there is no explicit event provider for the query requested, and WMI is required to poll for the condition. This interval is the maximum amount of time that can pass before notification of an event must be delivered.

condition
String

The condition to apply to events of the specified class.

groupWithinInterval
TimeSpan

The specified interval at which WMI sends one aggregate event, rather than many events.

groupByPropertyList
String[]

The properties in the event class by which the events should be grouped.

havingCondition
String

The condition to apply to the number of events.

Examples

The following example creates the event query: "SELECT * FROM __InstanceCreationEvent WHERE TargetInstance ISA Win32_NTLogEvent GROUP WITHIN 600 BY TargetInstance.SourceName HAVING NumberOfEvents > 15" which delivers aggregate events only if the number of Win32_NTLogEvent events received from the same source exceeds 15.

using System;
using System.Management;

public class EventSample
{
    public static void Main(string[] args)
    {
        // Requests sending aggregated events
        // if the number of events exceeds 15.
        String[] props = {"TargetInstance.SourceName"};
        WqlEventQuery q =
            new WqlEventQuery(
            "__InstanceCreationEvent",
            System.TimeSpan.MaxValue,
            "TargetInstance isa 'Win32_NTLogEvent'",
            new TimeSpan(0,10,0),
            props,
            "NumberOfEvents >15");

        Console.WriteLine(q.QueryString);
        return;
    }
}
Imports System.Management


Public Class EventSample
    Public Overloads Shared Function _
        Main(ByVal args() As String) As Integer

        ' Requests sending aggregated events
        ' if the number of events exceeds 15.
        Dim props() As String = {"TargetInstance.SourceName"}
        Dim t As New TimeSpan(0, 10, 0)
        Dim q As New WqlEventQuery("__InstanceCreationEvent", _
            System.TimeSpan.MaxValue, _
            "TargetInstance isa ""Win32_NTLogEvent""", _
            t, _
            props, _
            "NumberOfEvents >15")

        MessageBox.Show(q.QueryString)

    End Function 'Main
End Class

Remarks

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

Applies to