Share via


WqlEventQuery.EventClassName 屬性

定義

取得或設定要查詢的事件類別。

public:
 property System::String ^ EventClassName { System::String ^ get(); void set(System::String ^ value); };
public string EventClassName { get; set; }
member this.EventClassName : string with get, set
Public Property EventClassName As String

屬性值

傳回 String 值,內含事件查詢中的事件類別名稱。

範例

下列範例會初始化新的 WqlEventQuery ,並顯示事件查詢字串。

using System;
using System.Management;

public class EventSample
{
    public static void Main(string[] args)
    {
        WqlEventQuery query = new WqlEventQuery();
        query.EventClassName = "__InstanceCreationEvent";
        query.Condition = "TargetInstance ISA 'Win32_NTLogEvent'";
        query.GroupWithinInterval = new TimeSpan(0, 0, 10);
        System.Collections.Specialized.StringCollection collection =
            new System.Collections.Specialized.StringCollection();
        collection.Add("TargetInstance.SourceName");
        query.GroupByPropertyList = collection;
        query.HavingCondition = "NumberOfEvents > 25";

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


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

        Dim query As New WqlEventQuery
        query.EventClassName = "__InstanceCreationEvent"
        query.Condition = "TargetInstance ISA 'Win32_NTLogEvent'"
        query.GroupWithinInterval = New TimeSpan(0, 0, 10)
        Dim collection As New System.Collections.Specialized. _
            StringCollection
        collection.Add("TargetInstance.SourceName")
        query.GroupByPropertyList = collection
        query.HavingCondition = "NumberOfEvents > 25"

        MessageBox.Show(query.QueryString)

    End Function 'Main
End Class

備註

設定這個屬性值會覆寫儲存在 物件中的任何先前值。 系統會重建查詢字串,以反映新的類別名稱。

屬性值

字串,包含要查詢之事件類別的名稱。

.NET Framework 安全性

完全信任立即呼叫者。 這個成員無法供部分信任的程式碼使用。 如需詳細資訊,請參閱 使用部分信任程式代碼的連結庫

適用於