Click here to Skip to main content
15,036,145 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hello!
Here I am paste my some code snippets of cpp file.
C#
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.
C#
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
Updated 20-Mar-13 5:42am
v2
Comments
Leo Chapiro 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? :)

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().
   
Comments
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.
You could use the "main focus" of all "events":
C++
// 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... :)
   
v2

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




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900