PRB: Error Message Box Returned When DLL Load Fails |
Q117330
Under Windows NT, when you load a DLL, a message box titled "Invalid DLL Entrypoint" is displayed and has the following text:
Under Windows 95, the message box is titled "Error starting program" and the text is:The dynamic link library <name> is not written correctly. The stack pointer has been left in an inconsistent state. The entry point should be declared as WINAPI or STDCALL. Select YES to fail the DLL load. Select NO to continue execution. Selecting NO may cause the application to operate incorrectly.
The user is not given a choice to continue, only an OK button. Pressing the OK button fails program load.The <dll file name> file cannot start. Check the file to determine the problem.
The system expects DLL entrypoints to use the _stdcall convention. If you
use the _cdecl convention, the stack is not properly restored and
subsequent calls into the DLL can cause a general protection fault (GPF).
This error message is new to Windows NT, version 3.5. Under Windows NT,
version 3.1, the DLL is loaded without an error message, but the
application usually causes a GPF when calling a DLL routine.
Correct the prototype of your entrypoint. For example, if your entrypoint is as follows:
BOOL DllMain( HANDLE hDLL, DWORD dwReason, LPVOID lpReserved)
change it to the following:
BOOL WINAPI DllMain( HANDLE hDLL, DWORD dwReason, LPVOID lpReserved)
Then, link with the following linker option to specify the entry point if
you are using the C run-time:
-entry:_DllMainCRTStartup$(DLLENTRY)
If you are using the Microsoft C run-time, you need to use the entry point given in the RESOLUTION section in order to properly initialize the C run- time. For additional information, please see the following article in the Microsoft Knowledge Base:
Q94248 HOWTO: Use the C Run Time
For more information on the DLL entrypoint, please search on the topic DllEntryPoint in the Win32 API help file.
Additional query words:
Keywords : kbDLL kbKernBase kbGrpDSKernBase
Issue type : kbprb
Technology : kbAudDeveloper kbWin32sSearch kbWin32API
|
Last Reviewed: October 23, 2000 © 2001 Microsoft Corporation. All rights reserved. Terms of Use. |