Click here to Skip to main content
11,929,505 members (55,614 online)
Rate this:
Please Sign up or sign in to vote.
See more: MFC VisualC++
Here I am paste my some code snippets of cpp file.
typedef int(*pFunctionPointer2)(int,HANDLE);
typedef int(*pFunctionPointer3)(int,int,char*,HANDLE);
typedef int(*pFunctionPointer4)(FILE*,int,int,HANDLE);
typedef bool(*pFunctionPointer5)(HANDLE);
pFunctionPointer2 pFn2 = NULL;
pFunctionPointer3 pFn3 = NULL;
pFunctionPointer4 pFn4 = NULL;
pFunctionPointer5 pFn5 = NULL;
for e.g.
pFn2 = (pFunctionPointer2)GetProcAddress(hLib,"ADDNumber");

in which I used dll function, but there are different events of MFC dialogue based application.

So for each event all typedef functions should have to call, is there any way to declare in one function and call at once?
Posted 20-Mar-13 6:27am
Edited 20-Mar-13 6:42am
du[DE] 20-Mar-13 11:51am
Although I have edited this question I fear I have not understand it - so what do you want to do please? :)
Rate this: bad
Please Sign up or sign in to vote.

Solution 2

In a word, no there is no shortcut to defining, casting and assigning all of the method addresses.

The only way to get around this is to link to the dll in question rather than using LoadLibrary()/GetProcAddress().
nv3 20-Mar-13 15:05pm
That's what I would recommended. I have a feeling that OP actually wanted to link to the library, but somehow didn't know how.
Rate this: bad
Please Sign up or sign in to vote.

Solution 1

You could use the "main focus" of all "events":
// exported by DLL
// BOOL DllCheckMsg(MSG*);

// your.cpp
/*virtual*/ BOOL CYourDlgApp::PreTranslateMessage(MSG* pMsg)
However, the goal of the communication is not clear for me... Smile | :)

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web03 | 2.8.151126.1 | Last Updated 20 Mar 2013
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100