Posted by DaRKFoRCe on 2000-03-08
-----BEGIN PGP SIGNED MESSAGE----- Hi, Monday, March 06, 2000, 4:11:34 AM, you wrote: tgoa> Date: Sun, 5 Mar 2000 15:24:57 EST tgoa> From: Kspansel@xxx.xxx tgoa> Subject: Calling DLL functions tgoa> Hey all, tgoa> How would I go about calling a function from a DLL in C? I want to use tgoa> the windows cards.dll functions, but I don't know how to call them. And how tgoa> would I find out what they're prototypes look like? Any links and tgoa> information on using the cards.dll functions in C/C++ would be great. Thanks. tgoa> Kory Spansel Dunno if this helps, but you can call the exported functions just like calling any other functions, provided you link the import library for the .dll with your .exe. The library basically takes care about loading the apropriate dll and providing your .exe with its export table. This is load-time linking. Another way is run-time linking. You should not link your .exe with the import library. Instead, you load the dll at run time using LoadLibrary() or LoadLibraryEx() API, then you get the address of the function you want to invoke by GetProcAddress() API. Invoke the function by means of pointer to function then free the .dll if you don't need it anymore. The hard part is determining the function prototypes. I can't help you with that, but one suggestion, try 'quick-view'-ing the .dll file in explorer. The export table can be read there. Usually, the functions in a .dll uses pascal calling convention. To verify this, usually the function names in the export table are appended with '@some-number'. This shows that the function is using pascal conventions. The 'some-number' part shows how many bytes the function are expecting as argument. At least you know how many bytes to pass to the function. If you are desperate, you can always debug the exported functions by means of a window debugger (softice comes in mind). But it sure ain't pretty trying to figure out those asm opcodes cause source-level debugging is definitely out of question. DaRKFoRCe darkforce@xxxxxxxxxxx.xxx -----BEGIN PGP SIGNATURE----- iQEVAwUAOMPE3p5aDG9SPlWxAQF2OggAhrg+I38Go8zxrTmafax3ok76iCEVPgFK L+oFPgBuXZXiJv3LBi0TXbFUL06WE8I5AkxgfD3Haz8qcZhGVXd/9Wq5OSmeAmo4 vcXRXE/w94MbYU0Gi2ZgNarmtUBaYG046K8pHvXeohxDuoxPGDrn6OJ4CQIRmP6P rPQPcQ1i2PPRGnAylBB//CUHY4FWjt55jLnyUdP8Gt9Q70qCo9Rqjgxvgw/U8iDK F2xmVxZAmkaW4Gu6ht7KiA1qk2I+GHzYIJpYE77vnD/0ZMisIgRzKApH8++aHuVL dsJ3LAbQ16oDcHzHfMLBt7rrCZfoHh0y0pMHIs6oFk6ucj9XPbw+gQ== =kXQU -----END PGP SIGNATURE----- To signoff send a mail to listserver@xxxx.xx.xx with "signoff tcg" in the body of your message.
Previous post | Next post | Timeline | Home