且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

禁用“应用程序已停止工作”。窗口

更新时间:2021-11-16 22:30:12

我知道这是一个老问题,但我遇到了同样的问题,并找到了解决方案。

I know this is an old question, but I was having the same problem and found a solution.

在您的应用程序开始时调用以下命令:

Call the following at the start of your application:

SetErrorMode( SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX );

我已经用一个非常简单的尝试取消引用空指针的测试应用程序对其进行了尝试。如果没有上面的行,我的测试应用程序将显示 ...已停止工作对话框。

I've tried it with a very simple test application that attempts to dereference a null pointer. Without the line above, my test application would show "... has stopped working dialog." With the line above, the application just dies quietly.

参考:

  • Dialog Filter Windows Embedded Standard 7
  • MSDN: SetErrorMode function
  • pinvoke.net: SetErrorMode

编辑:这是一个选项用于在不修改代码的情况下在系统范围内禁用该对话框。将以下注册表值创建为REG_DWORD,并将其值设置为1:

Here's an option for disabling that dialog system-wide without modifying code. Create the following registry value as a REG_DWORD and set the value to 1:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\Windows Error Reporting\DontShowUI

参考: WER设置