Recently I have been learning about WMI and WQL. I found out the list of Win32 classes (from MSDN) that I can query for but I am not able to find out the list of event classes (should be the subset of the list of Win32 classes isn’t it ?) Does any one have a list or some kind of cheat sheet for this? I am jsut asking this out of curiosity.
Example for an event class – Win32_ProcessStartTrace
Here’s how to list WMI event classes in the
root\cimv2namespace with C# andSystem.Management:root\cimv2is the default WMI namespace so you don’t have to use aManagementScopeinstance. The WQL query passed toManagementObjectSearcheris a WMI metadata query. It uses:Meta_Classto designate the query as a schema query, and__Thisproperty to recursively list__Eventsubclasses(see here and here).
WMI class is an event class if its provider implemented as an event WMI provider and must be a subclass of
__Event. This doesn’t mean that you can’t use ‘ordinary’ WMI classes likeWin32_ProcessandWin32_Servicein WQL event queries. You just have to use one of the__InstanceOperationEventderived helper classes like__InstanceCreationEventor__InstanceDeletionEvent, and WMI will use its own event subsystem to deliver events.Here is a sample WQL query that subscribes to
Win32_Processcreation events:In this case you have to use the
Withinclause.