Главная страница | назад





Article #16574: How to import dll functions using MS's __stdcall.

 Question and Answer Database

FAQ1574C.txt   How to import dll functions using MS's __stdcall.
Category   :Linker
Platform    :All
Product    :BC++  5.x

Question:

When trying to create a .LIB-file from a DLL created in 
MSVC ++ 4.2 i get an error message from IMPLIB:

Exception C0000005: Access violation
Module: IMPLIB.EXE Start Adress: 00410000
...

(Creating a .LIB-file from winsock.dll works fine.)

I can create a .LIB that works by:
1. using DUMPBIN /EXPORTS...
2. create a .DEF-file with ordinals using information from 1 
3. using IMPDEF to create .LIB-file from .DEF-file

The problem with this approach is that the program cannot 
locate the functions in the DLL at runtime.

Does anyone have a solution?

Answer:

There is a workaround for MS DLL's that export using __stdcall
but it requires editing the .def produced by impdef by hand. 
When you imdef the dll your .def file
will look similar to this:

LIBRARY DLLNAME.DLL
EXPORTS
__funcname_1@8 = __funcname_1 @1
__funcname_2@4 = __funcname_2 @2

It needs to be changed to this:

IMPORTS
funcname_1=DLLNAME.__funcname_1@8
funcname_2=DLLNAME.__funcname_2@4

Add the def file to your project.

7/2/98 10:32:32 AM
 

Last Modified: 01-SEP-99