Hi,
According to your description, I think that you created a DLL project with MFC support. If my understanding is right, now the issue is how to use
our own DllMain when we create a MFC dll project.
When we try to use MFC library, we surely will include afx.h directly or indirectly, then MFC(afx.h) tell the linker to find the symbol of __afxForceUSRDLL
and put that object which contains __afxForceUSRDLL into the program, so linker searches and puts dllmodule.obj into our program, because __afxForceUSRDLL is defined in dllmodule.cpp.
That’s the common scenario. When we want to use our own DllMain in a mfc dll project,
linker complains that there are two DllMain, one in our code, one in Dllmodule.obj.
So we need to tell the linker to add our dllmain.obj for __afxForceUSRDLL. So we need to define __afxForceUSRDLL in our own cpp file where our own
DllMain is defined, then the linker will ignore mfc’s dllmodule.obj and see only one DllMain and never complains.
So my suggestion is to add extern “C” { int _afxForceUSRDLL; } in the file where your own DllMain is defined.
Hope this can help you.
Best Regards,
May
<THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
Thanks
MSDN Community Support
Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.