Eventlog侦听器-应用程序和服务 [英] Eventlog listener - Applications and Services

查看:106
本文介绍了Eventlog侦听器-应用程序和服务的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以监视应用程序和服务"的事件(在C#中)? 我发现我不能为此使用WMI.

Is there a way to watch events of "applications and services" when they are generated (in C#)? I've figured out that I can not use WMI for it.

还有其他想法吗?

推荐答案

您可以订阅

将条目写入本地计算机上的事件日志时发生.

Occurs when an entry is written to an event log on the local computer.

从MSDN:

    ....
    EventLog myNewLog = new EventLog();
    myNewLog.Log = "MyCustomLog";                      

    myNewLog.EntryWritten += new EntryWrittenEventHandler(MyOnEntryWritten);
    myNewLog.EnableRaisingEvents = true;                 

}       

public static void MyOnEntryWritten(object source, EntryWrittenEventArgs e){

}

这篇关于Eventlog侦听器-应用程序和服务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆