I am going through my project code base, which consits of libraries and applications. Some libraries are Dll's. Code is written in C++ for Windows using MS VS 2010.
I taught for Dll we should write DllMain function which is entry point for the DLL application. But in my project for DLL "DllMain" function is not present.
My question when we require DllMain and when it is not required?
Thanks for your time and help.
DllMain is not mandatory. If you have some initialization code required to run when loading the dll, you should create a DllMain function, and treat the initialization there. Otherwise it's not required. See here some more information.
The DllMain function is an optional method of entry into a dynamic-link library (DLL). If the function is used, it is called by the system when processes and threads are initialized and terminated, or upon calls to LoadLibrary and FreeLibrary.
In Visual C++, click the Browse tab in the Add References dialog box. Click Browse, locate the component that you want on your local drive, and then click OK. The component is added to the Selected Components field.
DllMain
is not mandatory. If you have some initialization code required to run when loading the dll, you should create a DllMain
function, and treat the initialization there. Otherwise it's not required.
See here some more information.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With