如何以编程方式检测Windows中已崩溃的应用程序? [英] How to programmatically detect an application has crashed in Windows?

查看:68
本文介绍了如何以编程方式检测Windows中已崩溃的应用程序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行一个Python脚本,该脚本可以启动许多应用程序.我需要一种方法来检测启动的应用程序是否崩溃.某些应用具有内部崩溃处理功能

I am running a Python script that launches a number of apps. I need a way to detect if the app that's launched has crashed. Some apps have internal crash handling

如何检测崩溃?

推荐答案

如果它们具有内部崩溃处理,将无法检测到.该应用程序将处理该错误并正常退出.如果您将自己附加为调试器,甚至无法检测到这一点.

If they have internal crash handling, it's not possible to detect. The application will handle the error and exit normally. You can't even detect this if you would attach yourself as a debugger.

原因是例外调度(MSDN):

  1. 调试器会收到有关异常的通知.这称为第一次机会异常.但是,这可能是正常"的,例如FileNotFound,这是应用程序所期望的.
  2. Windows正在寻找想要处理该异常的人.这可以是Python应用程序的 except 块,可以是C#或C ++中的 catch 块,甚至可以是常规的未处理的异常处理程序".
  3. 如果没有人希望处理该应用程序,则将再次通知调试器.这次,该异常被标记为第二次机会异常.这意味着该应用程序接下来将崩溃.
  1. the debugger gets informed about an exception. This is called the first chance exception. However, this might be "normal", e.g. FileNotFound, which is expected by the application.
  2. Windows is looking for someone who wants to handle the exception. This can be the except block of a Python application, a catch block in C# or C++ or even a general "unhandled exception handler".
  3. If nobody wanted to handle the application, the debugger gets informed again. This time, the exception is marked as a second chance exception. This means that the application will crash next.

您希望在第3步中获得通知,但是,该应用程序已经在第2步中停止了该过程.

You're looking to become informed as part of step 3, however, the application has already stopped the process in step 2.

这篇关于如何以编程方式检测Windows中已崩溃的应用程序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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