禁用异常处理并让Windows捕获它? [英] Disable exception handling and let windows catch it?
问题描述
我想禁用Delphi捕获的异常并让Windows捕获它-使其生成一个窗口,例如"AppName crashed.Debug,Send",将其添加到Application事件,创建内存转储,等等.
I want to disable the exception catching by Delphi and let Windows catch it - making it produce a window like "AppName crashed. Debug , Send", add this to Application events, create a memory dump and so on.
默认情况下,Delphi会在TApplication.Run过程中捕获所有异常...如何在不修改Forms.pas的情况下避免这种情况?
By default, Delphi catches all the exception in TApplication.Run procedure... How can I avoid that without modifying Forms.pas?
推荐答案
您可以设置 JITEnable
设置为"1"或更高(默认值为"0").对于非本地异常"1"(高于1),所有异常将由JIT或WER处理(取决于系统).
You can set JITEnable
to '1' or higher (default is '0'). With '1', non native exceptions, with higher than '1', all exceptions will be handled by JIT or WER (depending on the system).
这可能不是您想要的.使用此解决方案,任何符合条件的异常都将传递给操作系统,无论它们是否用代码处理都无关紧要.澄清(在调试器外部运行):
This may not be what you want though. With this solution any qualifying exception will be passed to the OS, it doesn't matter if they're handled in code or not. Clarification (run outside the debugger):
procedure TForm1.Button1Click(Sender: TObject);
begin
raise EAccessViolation.Create('access denied');
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
try
PInteger(0)^ := 0;
except
end;
end;
initialization
JITEnable := 1;
第一个示例是本机异常,当 JITEnable
为1时,它将由应用程序异常处理机制处理.但是第二个示例将触发JIT/WER.
The first example is a native exception, it will be handled by the application exception handling mechanism when JITEnable
is 1. But the second example will trigger JIT/WER.
这篇关于禁用异常处理并让Windows捕获它?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!