Question

this is more of conceptual question and it may be rather basic , i am not really finding good resources to learn about dll ,

i need to create dll(Load-time dynamic linking) which requires function1 to start on loading of dll and run at background for whole time ,

while function2 needs to exported which is going to be invoked several times by application,

function1 provides object which needs to be used in function2,

i am planning to use function1 as entry-point function(dllmain) while export function2.

as dllmain function called by system while exported function invoked by application ,do they run as two threads or as two separate processes?

also is it right to use dllmain and export as explained above to accomplish what i need?

Was it helpful?

Solution

"Advanced Windows" by Jeffrey Richter is one good place to learn about DLLs.

In your case something like this will do the job.

BOOL WINAPI DllMain(HINSTANCE hinstDLL,DWORD fdwReason,LPVOID lpvReserved)
{
   if (fdwReason == DLL_PROCESS_ATTACH)
   {
       //start thread with function1()
       begin_thread_ex(..., &function1, ....)
   }
}

__declspec(dllexport) function2()
{
    ....
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top