0
如何在Windows應用程序中檢測到新事件記錄在Windows事件日誌中。我目前正在運行的計時器以往5分鐘,以檢查是否有新的事件,但它會更好,如果我可以使用WMI或.net實時在Windows中記錄新事件時檢測
如何在Windows應用程序中檢測到新事件記錄在Windows事件日誌中。我目前正在運行的計時器以往5分鐘,以檢查是否有新的事件,但它會更好,如果我可以使用WMI或.net實時在Windows中記錄新事件時檢測
你需要建立一個WMI檢測新事件
謝謝Temporary Event Consumer在你的應用程序。請注意,以監控 事件日誌,您將需要請求SeSecurityPrivilege
在WMI連接(因爲它是可能的,你可能會收到來自安全日誌事件,這需要該權限)
這些都是一些例子WQL查詢:
// See all events:
select * from __InstanceCreationEvent where TargetInstance ISA 'Win32_NTLogEvent'
// Catch only specific events: 4202 is a network transport failure
select * from __InstanceCreationEvent where TargetInstance ISA 'Win32_NTLogEvent'
and TargetInstance.EventCode=4202
// Catch only events from a specific source: in this case WMI itself.
select * from __InstanceCreationEvent where TargetInstance ISA 'Win32_NTLogEvent'
and TargetInstance.SourceName='WinMgmt'
非常感謝你 –
@stuartd:你能幫我嗎(這裏)[http://stackoverflow.com/questions/28897897/c-monitor-process-creation-and-termination-in-windows] – Jackzz