DLL function pointer structure?

these are just some my function pointer prototype attempts
1
2
 typedef int (__cdecl *FNPTR)(LPWSTR);
typedef int (__cdecl *FNPTR)(int, char**);


and this is my handle and function pointer
1
2
3
4
FNPTR pFn;
HINSTANCE hIns;
hIns=LoadLibrary(TEXT("demo.DLL"));
pFn=(FNPTR)GetProcAddress(hIns,"PlayARound");

in my library header
1
2
3
4
5
6
7
#ifndef ASEXPORT
#include "quiz.h"
#define DLLIMPORTOREXPORT dllimport
#else
#define DLLIMPORTOREXPORT dllexport
#endif
extern "C"_declspec(DLLIMPORTOREXPORT) int PlayARound(int &score, int &numAsked, char roundName[]);

The demo.dll contains a function that plays a round of a quiz and then returns the score and the number of questions answered. I am informed that the function call should take this form:-

signature
int PlayARound(int &score, int &numAsked, char roundName[])
call
PlayARound(score, numAsked, "demo.dll");
...so yeah I get a value for the handle ok but the GetProcAddress always comes back null so I am obviously not calling the function correctly or something like that. When I say this is my code I mean this is my current code as I have tried numerous combinations of parameter passing and am now getting bored of dredging through forum threads and getting totally diverted.

ps. my directory linking and dependencies are all set and i have changed project defaults to accept multbyte instead of unicode.i have tried different calling conventions as well. i am using visual studio2010.
Last edited on
Is the function being exported?

Use Depends to show you the exported symbols to confirm it.
ok but how do I get the undecorated names, decorated?
The functions in the dll play a round of a quiz and then return the amount of questions asked and the score attained. I have a loadlibrary.lib file given to me as an example but now have to make my own.
Last edited on
depends has a button that shows the C++ names. But your function shouldn't be mangled as you've declared in extern "C"
Oh yes thats great! Turns out that the DLL has other functions that I need to be accessing so that my own version of PlayARound can work.Thanks for the help kbw you have gotten me back on track!
Topic archived. No new replies allowed.