Subj : Re: 32 bit Application calling a procedure inside a 32 bit DLL without link to it. To : borland.public.cpp.borlandcpp From : "Ed Mulroy [TeamB]" Date : Fri Jan 30 2004 08:54 am Do not declare the function pointer as FARPROC. Either cast the lvalue to FARPROC or do the more complex job of casting the return value of GetProcAddress to the pointer's type. I prefer casting the lvalue. In either of C or C++ you can call the function pointer in code as if it actually were the function. Here is a working example. If you want to build it from the command line a command to do so could be: bcc32 -WR progname.cpp ---------------- #include int WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int) { HINSTANCE hlib; int (WINAPI *mbox)(HWND, LPCTSTR, LPCTSTR, UINT); hlib = LoadLibrary("user32.dll"); if (hlib) { (FARPROC) mbox = GetProcAddress(hlib, "MessageBoxA"); mbox(HWND_DESKTOP, "Here I am!", "MessageBox Func", MB_OK); FreeLibrary(hlib); } return 0; } ---------------- I know of no practical way to call a 32 bit function from within a 16 bit application other than to write a 32 bit application and have the 16 bit one tickle it in a manner that the 32 bit one knows is to call that function, perhaps with a window message. In particular thunks vary greatly across the various versions of Windows and can be impossible to debug. .. Ed > akuma wrote in message > news:401a44c9@newsgroups.borland.com... > Hi, I want to call a dll function dynamicly just if the dll file > exist. The following is what I want to do: > > HINSTANCE hlib; > FARPROC proc1; > hlib = LoadLibrary("mydll.dll"); > > if (hlib) //the library exists > { > proc1 = GetProcAddress(hlib, "myfunc"); > > //need to call the procedure proc1 > //I can't found any API can do this like CallProc32W or > CallProcEx32W > //which designed for 16 bit application to call a 32 bit dll > //So, I would like to know which API and how to do this if > //myfunc have the prototype: > //int myfunc(int para1, LPSTR para2); > //... > > FreeLibrary(hlib); > } .