Subj : Re: EMS[CS]: Re: using LoadLibrary and GetProcAddress with MS DLL To : borland.public.cpp.borlandcpp From : Ed Mulroy [TeamB] Date : Thu Mar 17 2005 12:23 pm That is because I told you something which was wrong. To show the actual text of exports which have mangled names the command is: tdump -m -ee dllname.dll and not this, which is what I said before tdump -ee dllname.dll The '-m' is required so that tdump will show the mangling. Below is a simple example of an explicitly loaded DLL with name-mangled exports. Please let me know of 1-how the example worked on your machine and 2-if you are still having problems. -----TEST1.CPP----- #include void WINAPI MsgBox(const char *s, const char *title="Main Program") { MessageBox(HWND_DESKTOP, s, title, MB_OK); } int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { MsgBox("Before loading DLL"); HMODULE dll_hand = LoadLibrary("DLL1.DLL"); if (dll_hand) { typedef void (*FuncType)(); FuncType One = (FuncType) GetProcAddress(dll_hand, "@One$qv"); FuncType Two = (FuncType) GetProcAddress(dll_hand, "@Two$qv"); if (One) One(); else MsgBox("Unable to load address of One()", "Error"); if (Two) Two(); else MsgBox("Unable to load address of Two()", "Error"); FreeLibrary(dll_hand); } else { MsgBox("Error: Could not load DLL1.DLL"); } return 0; } -----DLL1.CPP----- #include BOOL WINAPI DllEntryPoint(HINSTANCE, DWORD, LPVOID) { return TRUE; } static void WINAPI MBox(const char *msg) { MessageBox(HWND_DESKTOP, msg, "From the DLL", MB_OK); } void __declspec(dllexport) One() { MBox("Function One()"); } void __declspec(dllexport) Two() { MBox("Function Two()"); } -----Commands to build----- bcc32 -W -v test1 bcc32 -WD -v dll1 --------------------------- .. Ed > Christian Schoett wrote in message > news:42397d44@newsgroups.borland.com... > > 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? .