ATL / WTL是否还需要使用全局_Module变量? [英] Does ATL/WTL still require the use of a global _Module variable?
问题描述
我刚刚开始一个新的ATL / WTL项目,我想知道是否仍然需要全局_Module变量?
I'm just starting up a new ATL/WTL project and I was wondering if the global _Module variable is still required?
回页首几年当我开始使用WTL时,需要定义一个全局变量(至少对于ATL 3.0):
Back a few years when I started working with WTL it was required (at least for ATL 3.0) that you define a global variable such as:
CAppModule _Module;
让ATL正常工作。但最近我读到某处,这可能不再需要了(但向导生成的代码仍然使用它)。我也通过Visual C ++包括目录搜索,它只在几个地方拾取_Module - 最引人注目的是ATL COM注册表的东西。
To get ATL to work correctly. But recently I've read somewhere that this may not be required anymore (yet the wizard generated code still uses it). Also I did a search through the Visual C++ include directories and it only picked up _Module in a few places - most notably the ATL COM registry stuff.
我仍然需要定义一个全局变量来使用ATL?
So do I still need to define a global variable to use ATL these days?
推荐答案
技术上你不需要一个全局 _Module
实例自ATL / WTL版本7.早期ATL / WTL代码引用 _Module
通过此特定名称,并希望您声明此对象的单个实例。此后,它被一个名为 _AtlBaseModule
的单实例对象替换,该对象在atlcore.h中为您自动声明。
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.
_Module 。
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
.
这篇关于ATL / WTL是否还需要使用全局_Module变量?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!