WMI 条目到达事件访问事件 ID
当我使用 WMI 监视事件日志时,尝试获取事件 ID 时遇到一个小问题。这是我的代码:
private static void EventLogMonitor(object sender, EventArrivedEventArgs e)
{
int realEventId = (int)(e.NewEvent.Properties["EventID"].Value);
...
但它无法为我获取事件 ID,只是抛出异常。有谁知道应该用什么来代替上面代码行中的 "EventID" ,以便我可以访问触发此处理程序的事件日志条目写入事件的事件 ID?
I am having a small problem trying to get the Event ID when I use WMI to monitor the event log. Here is my code:
private static void EventLogMonitor(object sender, EventArrivedEventArgs e)
{
int realEventId = (int)(e.NewEvent.Properties["EventID"].Value);
...
But it fails to pick up the Event ID for me, just throwing an exception. Does anybody know what should go in place of "EventID" in the line of code above so that I can access the Event ID of the event log entry written event that fires this handler?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我找到了如何做到这一点,对于其他发现这有用的人来说,这里是代码:
I found out how to do this, for anybody else that finds this useful here is the code: