Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: MFC VC++
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] at 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 at 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
0 Maciej Los 495
1 Sergey Alexandrovich Kryukov 429
2 OriginalGriff 360
3 CHill60 280
4 Sascha Lefévre 269
0 Sergey Alexandrovich Kryukov 10,017
1 OriginalGriff 9,495
2 Peter Leow 5,241
3 Kornfeld Eliyahu Peter 3,373
4 Maciej Los 3,076

Advertise | Privacy | Mobile
Web02 | 2.8.150327.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