How to load and use functions from DLL?

Started by ohmycee, August 17, 2011, 08:36:41 PM

Previous topic - Next topic

ohmycee

Hi all,

I'm starting a new post because the previous one has gone in a confusing direction. Here's my question:

I have a DLL: test.dll. It has 2 functions:
int ReturnNumber(void); // returns 98765
int ReturnAnotherNumber(int, int); // multiples both integers and returns the value

That's all I know about the dll. I don't have the sourcecode. I don't have the .lib.

To use the dll, I write the following. I call it usethedll.c:
#include <stdio.h>

int ReturnNumber(void);
int ReturnAnotherNumber(int, int);

int main (int argc, char **argv)
{
  printf("Test: %d\n", ReturnNumber()); //notice I can use the function simply by calling it, no need to loadlibrary or getprocaddress
  printf("Test: %d", ReturnAnotherNumber(8,9)); //same thing here
  return 0;
}


With GCC, I compile the code as such:
gcc -L. -ltest -o usethedll usethedll.c

My question is, how do I use test.dll as easily in Pelles C?

Thanks!

TimoVJL

#1
polib.exe test.dll /out:test.lib
cc -x usethedll.c test.lib kernel32.lib
May the source be with you

ohmycee