accessing a function from DLL

A

AS

Hi ,

I have exported the following function from a dll ,

extern "C" DECL_MYEXPORTS LRESULT CALLBACK MouseProc(int nCode,WPARAM
wParam,LPARAM lParam);



//in my calling code , I tried to access the function as below:

static HINSTANCE hinstDLL;

typedef LRESULT (CALLBACK *MOUSEPROC)(int nCode,WPARAM wParam,LPARAM
lParam); // typedef a function pointer to access the function

hinstDLL = LoadLibrary(_T("F:\\inter\\MyFirstDll\\debug\\MyFirstDll.dll"));
//hInstDLL is valid

MOUSEPROC hproc = (MOUSEPROC)GetProcAddress(hinstDLL,"MouseProc"); // hProc
is still NULL



Question: I'm not able to access the function thru GetProcAddress. Is the
typedef "typedef LRESULT (CALLBACK *MOUSEPROC)(int nCode,WPARAM
wParam,LPARAM lParam); " is corect or what is goin wrong here ?



Thanks



Sudhakar
 
T

Tom

MOUSEPROC hproc = (MOUSEPROC)GetProcAddress(hinstDLL,"MouseProc");  // hProc
is still NULL
Sudhakar

try the "Depency Walker" to check the DLL and see if the function is
exported under the right name. Sometimes the names are "decorated" by
the linker.

Thomas
 
A

AS

The function name is decorated, if I use the CALLBACK in the function
declaration ,

BUt tell me , how to get rid of this. THe function must have the prototype
" LRESULT CALLBACK MouseProc(int nCode,WPARAM wParam,LPARAM lParam);" in
the dll and it is exported with extern "C" But still it is decorated like
_MouseProc@12. Then, How can we use the exported function thru
GetProcAddress in the client application


with


MOUSEPROC hproc = (MOUSEPROC)GetProcAddress(hinstDLL,"MouseProc"); //
hProc
is still NULL
Sudhakar

try the "Depency Walker" to check the DLL and see if the function is
exported under the right name. Sometimes the names are "decorated" by
the linker.

Thomas
 
T

Tom

BUt tell me , how to get rid of this. THe function must have  the prototype

You can either use a .def file to define the exported names or you can
use numbers instead of numbers (you can pass the number of the
function to GetProcAddress);

Thomas
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,007
Latest member
obedient dusk

Latest Threads

Top