Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

MatrixCubed

GetProcAddress woes

This topic is 6029 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I have a function in a DLL defined as follows ... DWORD DLLFunction(DWORD val1, DWORD val2, DWORD* params ); ... So I''ve defined a function pointer to read from it ... DWORD (*lpDLLFunction)(DWORD val1, DWORD val2, DWORD* params ); ... but when I call the following ... lpDLLFunction = GetProcAddress(hLibrary, "DLLFunction"); .. I get the following error ... error C2440: ''='' : cannot convert from ''unsigned long (__stdcall *)(void)'' to ''unsigned long (__stdcall *)(unsigned long,unsigned long,long *)'' I''m not really sure what to do here. Should the function pointed be another type? Do I need to specify preprocessor directives? Any assistance is greatly appreciated. MatrixCubed
http://MatrixCubed.cjb.net

Share this post


Link to post
Share on other sites
Advertisement
Try this:

typedef unsigned long (*PFNDLLFunction)(DWORD, DWORD, DWORD *);

PFNDLLFunction lpDLLFunction = NULL;

lpDLLFunction = (PFNDLLFunction)GetProcAddress(hLibrary, "DLLFunction");

Note: that PFNDLLFunction is already a pointer to a function, so you don''t have to add a ''*'' to it.

-Brannon

Share this post


Link to post
Share on other sites
Oh yeah, I forgot to say that you always have to cast the result from GetProcAddress() to the proper function pointer type. Just in case this looked like a hack to make the compiler shutup. It is, but it''s one you have to use =).


-Brannon

Share this post


Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!