如何在程序崩溃时关闭程序,没有任何警告屏幕等.C++窗口



我正在用JUCE和C++做一个Windows程序,我希望它在崩溃时关闭。现在它显示崩溃对话框,您必须点击关闭。我不想显示任何东西,只是为了关闭它。可能吗?

谢谢。

找到了我需要的东西,它工作得很好。

#include <windows.h>
#include <rtcapi.h>
int exception_handler(LPEXCEPTION_POINTERS p)
{
printf("Exception detected during the unit tests!n");
exit(1);
}
int runtime_check_handler(int errorType, const char *filename, int linenumber, const char *moduleName, const char *format, ...)
{
printf("Error type %d at %s line %d in %s", errorType, filename, linenumber, moduleName);
exit(1);
}
int main()
{
DWORD dwMode = SetErrorMode(SEM_NOGPFAULTERRORBOX);
SetErrorMode(dwMode | SEM_NOGPFAULTERRORBOX);
SetUnhandledExceptionFilter((LPTOP_LEVEL_EXCEPTION_FILTER)&exception_handler); 
_RTC_SetErrorFunc(&runtime_check_handler);
// Run your tests here
return 0;
}

相关内容

最新更新