有什么方法可以在生成(在C#中)时观察“应用程序和服务”的事件吗? 我发现我无法使用WMI。
任何其他的想法?
您可以订阅EventLog.EntryWritten事件
在将条目写入本地计算机上的事件日志时发生。
来自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.EntryWritten事件 ?