Original Post
Hi everybody
is it possible to export a function pointer from a dll?
I want to set the function pointer in the DllMain and then call the function using a function pointer.
Example:
dll.h:
void (*pfnFUNC)(void); // Call functions using the pointer
dll.cpp:
void FunctionA(void) {/* Implementation */}
void FunctionB(void) {/* Implementation */}
int WINAPI DllMain(HINSTANCE hInstance,
DWORD fdwReason,
PVOID pvReserved)
{
if (A) pfnFUNC = FunctionA; // Set the func pointer
if (B) pfnFUNC = FunctionB;
// I get an error here, telling that the types don''t match
return 0;
}
client.cpp:
#include <dll.h>
bool SomeFunction(void)
{
// Call the correct function, specified on loading time
pfnFUNC();
}
1.) Can this be done this way?
2.) Is this a good idea :-) ?
3.) Is it possible to export a pointer at all - so I would use some kind of global functor using the strategy pattern. I was able to export a const char pointer.
Any help is greatly appreciated..
-Dirk