HOWTO: How to Provide Your Own DllMain in an MFC Regular DLL
2012-05-06 14:19
591 查看
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.
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.
相关文章推荐
- HOWTO: How to Provide Your Own DllMain in an MFC Regular DLL
- HOWTO: Provide Your Own Window Class Name for an MFC Dialog Box
- 码农如何快速打造一个有设计感的网站 How to Make Your Site Look Half-Decent in Half an Hour
- How To Write Your Own Ebook(r) In 7 Days!
- How to do android emma coverage test in your own ant scipts
- learn PCL 02 How to use pcl in your own project.
- How to create your own api with ACL in Magento
- How To Use WordBasic Functions in an MFC Automation Client for Word 97, Word 2000, Word 2002, or Word 2003
- How to Set Up Your Own Home Seedbox (in Windows)
- How to create your own custom 404 error page and handle redirect in SharePoint
- How to do android emma coverage test in your own ant scipts
- How to start a second thread in an MFC-based ActiveX control to fire events in Visual C++
- How to Build an Economic Model in Your Spare Time (如何利用业余时间建立经济模型)
- how to increase an regular array length in java?
- How to use an external dll file in VisualStudio project
- ow to use DllMain in a MFC dll project (ZZ
- How to use an external dll file in VisualStudio project
- 转:How to create your own custom 404 error page and handle redirect in SharePoint 2007 (MOSS)?
- git tip: How to undo an uncommitted change/deletion for a specific file in your working directory
- How to resolve "your security settings have blocked an untrusted application from running" in Mac