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)
|
dlopen(const char *fn, int flags)
|
||||||
{
|
{
|
||||||
HMODULE hm;
|
HMODULE hm;
|
||||||
|
UINT old_error_mode;
|
||||||
|
|
||||||
/* We don't support dlopen(0, ...) on Windows.*/
|
/* We don't support dlopen(0, ...) on Windows.*/
|
||||||
if ( fn == NULL ) {
|
if ( fn == NULL ) {
|
||||||
@@ -141,12 +142,16 @@ dlopen(const char *fn, int flags)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
old_error_mode = SetErrorMode(SEM_FAILCRITICALERRORS);
|
||||||
|
|
||||||
hm = LoadLibrary(fn);
|
hm = LoadLibrary(fn);
|
||||||
|
|
||||||
if (hm == NULL) {
|
if (hm == NULL) {
|
||||||
set_error_from_last();
|
set_error_from_last();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetErrorMode(old_error_mode);
|
||||||
|
|
||||||
return (void *) hm;
|
return (void *) hm;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user