WMIEvent 类列表
最近在学习WMI和WQL。 我找到了可以查询的 Win32 类列表(来自 MSDN),但我无法找到事件类列表(应该是 Win32 类列表的子集,不是吗?)有一个清单或某种备忘单吗? 我只是出于好奇才问这个问题。
事件类示例 - Win32_ProcessStartTrace
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
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
以下是如何使用 C# 和 System.Management 列出
root\cimv2
命名空间中的 WMI 事件类:root\cimv2
是默认的 WMI 命名空间,因此您不必使用ManagementScope
实例。 传递给ManagementObjectSearcher
的 WQL 查询是 WMI 元数据查询。 它使用:Meta_Class
将查询指定为架构查询,并使用__This
属性递归列出__Event
子类(请参阅此处和此处)。
如果 WMI 类的提供程序实现为事件 WMI 提供程序,则 WMI 类是事件类,并且必须是 __Event 的子类。 这并不意味着您不能在 WQL 事件查询中使用“普通”WMI 类,例如
Win32_Process
和Win32_Service
。 您只需使用__InstanceOperationEvent
派生帮助器类之一,例如__InstanceCreationEvent
或__InstanceDeletionEvent
,WMI 将使用其自己的事件子系统来传递事件。以下是订阅
Win32_Process
创建事件的示例 WQL 查询:在这种情况下,您必须使用
Within
子句。Here's how to list WMI event classes in the
root\cimv2
namespace with C# andSystem.Management
:root\cimv2
is the default WMI namespace so you don't have to use aManagementScope
instance. The WQL query passed toManagementObjectSearcher
is a WMI metadata query. It uses:Meta_Class
to designate the query as a schema query, and__This
property to recursively list__Event
subclasses(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_Process
andWin32_Service
in WQL event queries. You just have to use one of the__InstanceOperationEvent
derived helper classes like__InstanceCreationEvent
or__InstanceDeletionEvent
, and WMI will use its own event subsystem to deliver events.Here is a sample WQL query that subscribes to
Win32_Process
creation events:In this case you have to use the
Within
clause.WMI 代码创建器是学习 WMI 的一个很好的工具,除其他外,它可以让您探索本地或远程计算机上的 WMI 事件类并生成用于接收事件通知的代码。
编辑:由于您将问题标记为C#,您可能对以编程方式获取从特定类派生的事件类列表的代码感兴趣:
WMI Code Creator is a great tool for learning WMI that, among other things, lets you explore WMI event classes on the local or remote computer and generate code for receiving event notifications.
Edit: Since you tagged your question as C#, you might be interested in the code for getting the list of event classes derived from a particular class programmatically:
MSDN 没有列出所有 MSMCA 类吗
更新:
我没有使用 WMI 进行大量工作,但我刚刚发现了这个 WMI 工具 会很有帮助。 它为您提供了一个用于查看对象的 WMI 层次结构的 GUI,甚至允许您注册和使用事件。 这应该会为您提供所需的信息。
Doesn't MSDN have a list of all the MSMCA classes here
UPDATE:
I don't do tons of work with WMI, but I just found this WMI tool that would have been helpful. It gives you a GUI for viewing the WMI hierarchy of objects, and even allows you to register and consume events. This should give you the information you need.