Rediger

Del via


Creating a WMI Sink for Auditing and Logging Events

You can use the following sample code to create a Windows Management Instrumentation (WMI) sink to monitor auditing and logging events:

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

See Also

Programming Guide