From 4795dc3b1fac0e8547bbe8165695858edda0f380 Mon Sep 17 00:00:00 2001 From: Nils Maier Date: Sun, 4 Dec 2011 00:00:49 +0100 Subject: [PATCH] Windows: fix errormode By default Windows will pop up that nasty "Send Information" dialog when the application crashes. This will feed some information back to MS, if the user confirms, but has no real added value. Instead, it breaks batch processing, as that dialog requires user interactions. Therefore disable this cruft. Signed-off-by: Nils Maier --- src/common/common.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/common/common.cpp b/src/common/common.cpp index 20df35af9..2ab471585 100644 --- a/src/common/common.cpp +++ b/src/common/common.cpp @@ -33,6 +33,25 @@ #define matroska_done() #endif +#if defined(SYS_WINDOWS) +typedef UINT (WINAPI *pGetErrorMode)(void); +static void fix_windows_errormode() { + UINT mode = SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX; + HMODULE hKern = ::LoadLibrary("kernel32"); + if (hKern) { + // Vista+ only, but one can do without + pGetErrorMode _GetErrorMode = reinterpret_cast( + ::GetProcAddress(hKern, "GetErrorMode") + ); + if (_GetErrorMode) + mode |= _GetErrorMode(); + + ::FreeLibrary(hKern); + } + ::SetErrorMode(mode); +} +#endif + // Global and static variables unsigned int verbose = 1; @@ -98,6 +117,10 @@ mtx_common_cleanup() { void mtx_common_init() { +#if defined(SYS_WINDOWS) + fix_windows_errormode(); +#endif + matroska_init(); atexit(mtx_common_cleanup);