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.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user