Communication from DLL to a application

How can I call a function in the application from the DLL ?
Is it possible thro CALLBACK? If so please specify how?
Thank U
aacAsked:
Who is Participating?
 
IgorGrebnevConnect With a Mentor Commented:
Dear aac,

You can transfer the pointer to funciton in executable to DLL through pointer to function. The following code can be used
In EXE:

int ExportedFromEXEFunc()

{ return 0;
}

In DLL you should implement the following:

typedef int (*typePtrExpFunc)();

static typePtrExpFunc stm_pFunc = NULL;
 
declspec(_dllexport) void SetEXE_ExportedFunc( typePtrExpFunc pfExpFunc )

{stm_pFunc = pfExpFunc;
}

After calling the SetEXE_ExportedFunc from EXE and setting of static pointer to funciton in executable you can call the function through pointer anywhere in DLL:

(*stm_pFunc)();

0
 
aacAuthor Commented:
Instead of using declspec to export the function can I use it directly in my .def file?
0
All Courses

From novice to tech pro — start learning today.