Improve error handling when loading DLLs

This commit is contained in:
U-Khasa\Vitor 2009-07-20 20:55:22 -07:00
parent b9e10203bd
commit d67332dc19
2 changed files with 10 additions and 5 deletions

15
C/load_dll.c Normal file → Executable file
View File

@ -47,13 +47,18 @@ LoadForeign(StringList ofiles, StringList libs,
if (Yap_TrueFileName(ofiles->s, Yap_FileNameBuf, TRUE) && if (Yap_TrueFileName(ofiles->s, Yap_FileNameBuf, TRUE) &&
(handle=LoadLibrary(Yap_FileNameBuf)) != 0) (handle=LoadLibrary(Yap_FileNameBuf)) != 0)
{ {
if (*init_proc == NULL) Yap_ErrorSay[0]=~'\0';
*init_proc = (YapInitProc)GetProcAddress((HMODULE)handle, proc_name); if (*init_proc == NULL)
} *init_proc = (YapInitProc)GetProcAddress((HMODULE)handle, proc_name);
} else {
FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(),
MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), Yap_ErrorSay, 256,
NULL);
}
ofiles = ofiles->next; ofiles = ofiles->next;
} }
/* load libraries first so that their symbols are available to /* load libraries first so that their symbols are available to
other routines */ other routines */
while (libs) { while (libs) {

0
C/load_foreign.c Normal file → Executable file
View File