Subj : EMS[CS]: Re: using LoadLibrary and GetProcAddress with MS DLL To : borland.public.cpp.borlandcpp From : Christian Schoett Date : Thu Mar 17 2005 01:52 pm Ed, Thank you for your quick answer. The target is 32bit and the compiler is Borland C++ Builder. I noticed that I chose the wrong group to post my question, sorry for that. I have inspected code and exports again and recompiled everything. Please do not ask why, but now it works ... I have however encountered another problem now. Let me try to explain what I want to do: before: application links import library (Microsoft or Borland obtained through 'implib') and accesses the DLL functions directly. Works fine now: application links custom library that loads DLL at runtime and assigns functions via GetProcAddress. The application interface looks exactly the same like the old one but now I can execute some supplementary code within my custom library before calling the DLL. Of course the library file is much bigger than the old one Now my problem: 1. I create a test application with the C files that will go into the library. Everything works fine. 2. I create the library and then link it to a test application. The linker comes up with unresolved externals for all the library functions. Did I miss sometehing when creating the library. Do I have to do something else than just adding the library file to my test project? Kind regards, Chris "Ed Mulroy [TeamB]" schrieb im Newsbeitrag news:423970da@newsgroups.borland.com... > As Borland C++ can create programs for either of 16 bit Windows or 32 > bit Windows, when you ask a question please mention which of those is > the target type in your situation. > > It sounds as if your diagnosis is correct. The symptoms you describe > are exactly what occurs when the name given to GetProcAddress does not > match that found in the DLL. > > Just for the heck of it, make one more pass through the code to insure > that the handle returned from LoadLibrary is both checked for NULL > (Win32) or for a value <= HINSTANCE_ERROR (16 bit Windows) and that > handle is actually the one passed as the first argument to > GetProcAddress. > > Look at the contents of the *.def file, the module definition file. > In it are the public names of the exported functions. Those names are > what should be given to GetProcAddress. > > You can also see the exact text of the public names exported from a > DLL by giving a command like this: > > A command like this will also show the exact text of a DLL's exported > names : > > tdump -ee DllName.DLL > > Side note: > > An import library is just an alternate means to implicitly link to a > DLL. You can do it by adding either of a module definition file or an > import library to the project. The results should be the same from > either. > > . Ed > > > Christian Schoett wrote in message > > news:42394141$1@newsgroups.borland.com... > > > > I have a DLL created with Visual C. It uses a .def file to export > > the > > functions. Until now, I used implib to create a .lib file that can > > be > > linked to applications created with Borland C++ Builder. Now I > > want to load the DLL dynamically from a static library created > > with Borland builder using 'LoadLibrary' and 'GetProcaddress'. > > 'LoadLibrary' is successful but 'GetProcAddress' always returns > > NULL for all functions. I guess it has something to do with the > > name mangling but may someone has a hint how to solve this > > problem. > > .