patch 8.2.3208: dynamic library load error does not mention why it failed
Problem: Dynamic library load error does not mention why it failed.
Solution: Add the error message. (Martin Tournoij, closes #8621)
diff --git a/src/os_win32.c b/src/os_win32.c
index eff2269..91bd18a 100644
--- a/src/os_win32.c
+++ b/src/os_win32.c
@@ -716,7 +716,7 @@
if (p_verbose > 0)
{
verbose_enter();
- semsg(_(e_loadlib), GETTEXT_DLL);
+ semsg(_(e_loadlib), GETTEXT_DLL, GetWin32Error());
verbose_leave();
}
return 0;
@@ -8353,3 +8353,19 @@
}
}
#endif
+
+ char *
+GetWin32Error(void)
+{
+ char *msg = NULL;
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER|FORMAT_MESSAGE_FROM_SYSTEM,
+ NULL, GetLastError(), 0, (LPSTR)&msg, 0, NULL);
+ if (msg != NULL)
+ {
+ // remove trailing \r\n
+ char *pcrlf = strstr(msg, "\r\n");
+ if (pcrlf != NULL)
+ *pcrlf = '\0';
+ }
+ return msg;
+}