Process
类型的Responding
属性判断(不好用)WerFault.exe
进程,这个就是上个方法中出现已停止的弹出窗口进程,需要判断到底是哪一个进程出错(通过WerFault.exe可以获取到指定进程的名称非完整路径)WerFault.exe
进程,获取句柄,然后获取窗体内容(性能好难度高)使用EventLog
类获取windows事件
const string _shutdownKey = "Application Error";
const string _appdomain = "Application";
var date=DateTime.Now.AddDays(-1);
using (EventLog log = new EventLog(_appdomain))
{
foreach (EventLogEntry item in log.Entries)
{
if (item.EntryType != EventLogEntryType.Error) continue;
if (item.TimeGenerated < date) continue;
if (item.Source != _shutdownKey) continue;
//item.ReplacementStrings长度为13时为.net程序崩溃错误
if (item.ReplacementStrings.Length != 13) continue;
//item.ReplacementStrings[10] 为进程完整路径
Console.WriteLine(item.ReplacementStrings[10]);
}
}