SetErrorMode(0);
LoadLibrary("foo.dll");
I get a window with the error message:
"The procedure entry point bar could not be located in the dynamic
link library baz.exe"
(the reason is that foo.dll calls bar() which is defined in baz.exe
without __declspec(dllexport)).
and LoadLibrary returns NULL
However, if I use FormatMessage to get the error message instead:
FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER |
FORMAT_MESSAGE_FROM_SYSTEM
| FORMAT_MESSAGE_IGNORE_INSERTS,
NULL, GetLastError(), 0, (char*)&buf, 0, NULL);
I get this:
"The specified procedure could not be found."
Note that the crucial bits of information (function name bar and dll
name baz) are missing.
Is there a way to get the same error message which is displayed in the
error window using FormatMessage?
Thanks.
Sam.
> Is there a way to get the same error message which is displayed
> in the error window using FormatMessage?
No, there is not. The error message you are looking for is generated by the
OS Executable Loader itself when resolving its statically-linked inports.
It is not generated by LoadLibrary() or anything else in the Win32 API, and
thus is not accessible in your code.
--
Remy Lebeau (TeamB)