Does ATL/WTL still require the use of a global _Module variable?

北城以北 提交于 2019-12-05 17:01:52

Technically you do not need a global _Module instance since ATL/WTL version 7. Earlier ATL/WTL code referenced _Module by this specific name and expected you to declare a single instance of this object. This has since been replaced by a single instance object named _AtlBaseModule that is automatically declared for you in atlcore.h.

Having said that, though, some of the best WTL features are contained within CAppModule and its base class CComModule. Automatic COM registration, message loop handling, etc. So most non-trivial WTL based apps will still want a singleton instance of a CComModule base class. However, it doesn't need to be named _Module.

In the sample projects of the latest WTL version, this is still used.

In stdafx.h:

extern CAppModule _Module;

In implementation files:

CAppModule _Module;
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!