I created a dll file, and I wanted the resources it uses to be initialized when the dll gets loaded, so I wanted to include DllMain function in the dll file.
Code:
// DllMain.cpp
#include "windows.h"
int WINAPI DllMain(HINSTANCE hInstance, DWORD dwReason, LPVOID /*pReserved*/)
{
...Do Initialization...
}
Do I need to compile DllMain.cpp file along with the sources for the dll
file for the above DllMain() function to be called? or can I 1) compile the dllmain.cpp file into a .lib library file 2) statically link the library to the dll during a link-time?
Also, do I need to export the DllMain function (using the.def file for the dll file)? Thanks!