Programming Tips - How can I avoid this error: nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MyThing.obj

Date: 2010feb19 Language: C/C++ OS: Windows Q. How can I avoid this error: nafxcwd.lib(dllmodul.obj) : error LNK2005: _DllMain@12 already defined in MyThing.obj A. This happens when you have a DllMain in a DLL that uses MFC. MFC has its own DllMain (in nafxcwd.lib). If you are going to use MFC you can't have a DllMain. If you simply want to get the instance handle you can use
hHandle = AfxGetInstanceHandle();
in your DLL. To do more you need to define your own class based on CWinApp and do initialization in InitInstance();
class CMyClass : public CWinApp { public: virtual BOOL InitInstance(); }