存储其他程序的事件 [英] Store events from other programs
本文介绍了存储其他程序的事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想在其他应用程序中存储其他应用程序的事件。事件的例子:当Word打开,最小化或文件被打开。
I want to store events from other applications in my own app. Examples of events: when Word is opened, minimized or a file is opened.
这样的事情可能吗?
推荐答案
使用 EventLog
。
您必须设置 EnableRaisingEvents
属性为 true
当事件添加到指定的事件日志
EntryWritten
事件处理程序将提高
And When an event add to specified event log the
EntryWritten
event handler will raise
这是最简单的方式处理os
事件
It is the simplest way to handle os events
示例代码
private void frmMain_Load(object sender, EventArgs e)
{
System.Diagnostics.EventLog s = new System.Diagnostics.EventLog("Application", ".", "");
s.EnableRaisingEvents = true;
s.EntryWritten += delegate(object st, System.Diagnostics.EntryWrittenEventArgs ew)
{
MessageBox.Show(ew.Entry.Message);
};
}
这篇关于存储其他程序的事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文