Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: MFC VC++
Hello!
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
_duDE_8.1K
v2
Comments
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
good
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().
  Permalink  
Comments
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
good
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)
{
  (*m_pfnDllCheckMsg)(pMsg);
    
  CWinApp(Ex)::PreTranslateMessage(pMsg);
}
However, the goal of the communication is not clear for me... Smile | :)
  Permalink  
v2

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

  Print Answers RSS
0 OriginalGriff 350
1 Jochen Arndt 190
2 Richard MacCutchan 135
3 Sergey Alexandrovich Kryukov 130
4 DamithSL 105
0 OriginalGriff 6,045
1 DamithSL 4,601
2 Maciej Los 4,087
3 Kornfeld Eliyahu Peter 3,480
4 Sergey Alexandrovich Kryukov 3,310


Advertise | Privacy | Mobile
Web01 | 2.8.141220.1 | Last Updated 20 Mar 2013
Copyright © CodeProject, 1999-2014
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