From 0ae44152b70bbc303868bb1966f6acaaf99d6544 Mon Sep 17 00:00:00 2001 From: "Asanka C. Herath" Date: Mon, 22 Nov 2010 15:01:41 -0500 Subject: [PATCH] Windows: Set error mode before calling LoadLibrary() Unless SEM_FAILCRITICALERRORS is set, Windows may pop-up a dialog box if the specified module cannot be loaded. This is not appropriate for unattended or batch processes. --- lib/roken/dlfcn_w32.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/roken/dlfcn_w32.c b/lib/roken/dlfcn_w32.c index d7eab07c2..9379661df 100644 --- a/lib/roken/dlfcn_w32.c +++ b/lib/roken/dlfcn_w32.c @@ -134,6 +134,7 @@ ROKEN_LIB_FUNCTION void * ROKEN_LIB_CALL dlopen(const char *fn, int flags) { HMODULE hm; + UINT old_error_mode; /* We don't support dlopen(0, ...) on Windows.*/ if ( fn == NULL ) { @@ -141,12 +142,16 @@ dlopen(const char *fn, int flags) return NULL; } + old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS); + hm = LoadLibrary(fn); if (hm == NULL) { set_error_from_last(); } + SetErrorMode(old_error_mode); + return (void *) hm; }