Reputation: 199
I have created a DLL in C++ and have successfully been able to use it in another application. What I would like to is to use a function in my application code - NOT THE DLL - and be able to use that function within the DLL.
Is this possible? Thanks.
Upvotes: 0
Views: 116
Reputation: 98974
Sure - if you can call functions in your DLL, you can e.g. pass function pointers to it from the hosting application (or another DLL in the same process) and then call those:
// DLL side:
typedef void (*CallbackFunc)();
APISTUFF void dllFunction(CallbackFunc f) {
f();
}
// hosting app side:
void hostFunction() {
// ...
}
void doPluginStuff() {
// ... load DLL, resolve dllFunction, etc.
dllFunction(&hostFunction);
}
That is how C-style plugin APIs like NPAPI work.
Upvotes: 4