By design, MFC Regular DLLs have a default DllMain function provided automatically by MFC. Regular DLLs should not provide their own DllMain. Any initialization which is necessary when the DLL is loaded should be done in the InitInstance member function of the one CWinApp-derived class in the Regular DLL. Deinitialization and termination code should go in the ExitInstance member function.
However, InitInstance is only called by MFC's DllMain when a process attaches (DLL_PROCESS_ATTACH) to the DLL and ExitInstance is called only when a process detaches (DLL_PROCESS_DETACH) from the DLL. If it is necessary to handle thread attachment to and detachment from (DLL_THREAD_ATTACH and DLL_THREAD_DETACH) in MFC Regular DLL, the Regular DLL will need to provide its own DllMain. This article explains how to do it.
However, InitInstance is only called by MFC's DllMain when a process attaches (DLL_PROCESS_ATTACH) to the DLL and ExitInstance is called only when a process detaches (DLL_PROCESS_DETACH) from the DLL. If it is necessary to handle thread attachment to and detachment from (DLL_THREAD_ATTACH and DLL_THREAD_DETACH) in MFC Regular DLL, the Regular DLL will need to provide its own DllMain. This article explains how to do it.