在C中禁用崩溃对话框
我想禁用(在VS2010 C程序中)GPF发生时弹出的崩溃对话窗口(您知道 xxx.exe已停止工作)
I would like to disable (in a VS2010 C program) the crash dialog window which pops up on screen when a GPF occurred (You know the xxx.exe as stopped working)
我试过win2008和win7:
I tried on win2008 and win7:
- SetErrorMode(SetErrorMode(SEM_NOGPFAULTERRORBOX)|SEM_FAILCRITICALERRORS);
- try/catch (with SEH, but some parts of the code aren't wrapped in)
- SetUnhandledExceptionFilter()
没有什么工作...仍然有这个死的窗口
Nothing works... still with this damned window
我忘记了什么吗?
唯一正在工作的是修改寄存器库
中的DontShowUI键( HKEY_LOCAL_MACHINE \Software \Microsoft\Windows \Windows错误报告 )
但它只是不干净,我更喜欢一个编码解决方案(我不能改变寄存器到我的代码!)
The only thing which is working is to modify the "DontShowUI" key in register base (HKEY_LOCAL_MACHINE\Software\Microsoft\Windows\Windows Error Reporting) but it's just not clean, and I would prefer a "coding" solution (and I cannot change the register into my code !)
一个主意 ? (除了修复程序本身以避免GPF当然:)
Do you have an idea ? (except fixing the program itself to avoid the GPF of course :)
感谢...
有趣的是,在Cygwin下,崩溃对话框不显示!
note : Interesting, under Cygwin the crash dialog doesn't appear !
禁用崩溃框的最好方法是删除任何代码是导致您的程序崩溃。
The best way to disable the crash box is to remove whatever code is causing your program to crash. This box will never appear for a correct program.
编辑: SetErrorMode
,应为:
SetErrorMode(SetErrorMode(SEM_NOGPFAULTERRORBOX)
|SEM_FAILCRITICALERRORS|SEM_NOGPFAULTERRORBOX);
或类似。我想你错误地阅读了你在评论中引用的博客文章。
or similar. I think you misread the blog article you cited in the comments.