如何防止Vista在例外情况下杀死我的程序?

时间:2022-05-18 22:47:10

It used to be that if an exception got raised and propagated far enough up the call stack, Application's main loop would handle it and give you a dialog box. That behavior seems to be broken under Windows Vista. If any exception reaches that level, Vista steps in and says the program "has stopped working," when it used to be perfectly able to continue under XP. (That's the entire reason the exception handler in the main loop is there, for heaven's sake!)

过去,如果异常被提升并在调用堆栈上传播得足够远,Application的主循环将处理它并为您提供一个对话框。在Windows Vista下,这种行为似乎被打破了。如果任何异常达到该级别,Vista会介入,并表示该程序“已停止工作”,此时它曾完全能够在XP下继续运行。 (这就是为什么上帝的缘故,主循环中的异常处理程序存在的全部原因!)

Is there any way to fix this? Preferably in my code itself and not just on my computer, so it won't screw up on other systems?

有没有什么办法解决这一问题?最好是在我的代码本身而不仅仅是在我的计算机上,所以它不会搞砸其他系统?

3 个解决方案

#1


Check to ensure that the global variable in System, JITEnable is still set to 0. If that variable is set to 1, hardware (and external) exceptions will cause that behavior by calling UnhandledExceptionFilter. If it is set to 2, any exception will cause it.

检查以确保System,JITEnable中的全局变量仍设置为0.如果该变量设置为1,则硬件(和外部)异常将通过调用UnhandledExceptionFilter导致该行为。如果设置为2,则任何异常都将导致它。

#2


You should add an application level exception handler, http://www.chami.com/tips/delphi/011497D.html. Also you should look into running madexcept to determine why these exceptions are happening, so they can be fixed.

您应该添加应用程序级异常处理程序,http://www.chami.com/tips/delphi/011497D.html。此外,您应该查看运行madexcept以确定为什么会发生这些异常,因此可以修复它们。

#3


Unfortunately, not all exceptions were nicely caught, even in XP. Ever had an application just vanish, ot just hanging and needing a pskill? (some Delphi version anyone?)
I would try to plug EurekaLog in your app and see if it gives some information on what happens.

不幸的是,即使在XP中,并非所有异常都被很好地捕获。曾经有一个应用程序消失,ot只是悬挂,需要一个pskill? (有些Delphi版本的人吗?)我会尝试在你的应用程序中插入EurekaLog,看看它是否提供了一些有关发生的事情的信息。

#1


Check to ensure that the global variable in System, JITEnable is still set to 0. If that variable is set to 1, hardware (and external) exceptions will cause that behavior by calling UnhandledExceptionFilter. If it is set to 2, any exception will cause it.

检查以确保System,JITEnable中的全局变量仍设置为0.如果该变量设置为1,则硬件(和外部)异常将通过调用UnhandledExceptionFilter导致该行为。如果设置为2,则任何异常都将导致它。

#2


You should add an application level exception handler, http://www.chami.com/tips/delphi/011497D.html. Also you should look into running madexcept to determine why these exceptions are happening, so they can be fixed.

您应该添加应用程序级异常处理程序,http://www.chami.com/tips/delphi/011497D.html。此外,您应该查看运行madexcept以确定为什么会发生这些异常,因此可以修复它们。

#3


Unfortunately, not all exceptions were nicely caught, even in XP. Ever had an application just vanish, ot just hanging and needing a pskill? (some Delphi version anyone?)
I would try to plug EurekaLog in your app and see if it gives some information on what happens.

不幸的是,即使在XP中,并非所有异常都被很好地捕获。曾经有一个应用程序消失,ot只是悬挂,需要一个pskill? (有些Delphi版本的人吗?)我会尝试在你的应用程序中插入EurekaLog,看看它是否提供了一些有关发生的事情的信息。