Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling functions from DLLs 1

Status
Not open for further replies.

hencox

Technical User
Sep 5, 2001
6
SE
Hi!

I'm trying to call a function from within a DLL by using this code:

Code:
FUNCPNT* fP;

HINSTANCE hLib = LoadLibrary("the_api.dll");
	
if(hLib)
{
  fP = (FUNCPNT*)GetProcAddress(hLib,"TheDLLFunction");
}

//the calling of the function
(*fP)();

This gives me the error "error C2064: term does not evaluate to a function" on the last line, when compiling in Visual C++. Any ideas what I have missed?

Regards
Henrik

 
When reading my post, I realize that I expressed myself a little bit fuzzy perhaps. What I want to do is call a funtion that resides in a DLL.
 
You need to define the signature of the function
Code:
typedef void (*FUNCPNT)(void);
FUNCPNT fptr = (FUNCPNT)GetProcAddress(…);
(fptr);


-pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top