为审核与记录事件创建 WMI 接收器
可以使用以下示例代码创建 Windows Management Instrumentation (WMI) 接收器,以监视审核和日志记录事件:
//Create the WMI query and Event watcher and subscribe to events
ManagementEventWatcher watcher = new ManagementEventWatcher ("root/Default", "select * from PackageEvent");
ManagementBaseObject evtObj = watcher.WaitForNextEvent();
//Do what you want with the event