OBJECT_ENTRY_AUTO

330 篇文章 ¥19.90 ¥99.00
ATLMacros示例展示了如何使用新的ATL宏替代旧的组合。该样本基于由AppWizard创建的ATL项目,演示了如何在不使用C++属性的情况下创建DLL项目。在VC6中,通过Object Map和`OBJECT_ENTRY_AUTO`宏管理COM类,而在VC7中,使用`OBJECT_ENTRY_AUTO`代替,使得全局范围内的对象条目更简单,所有类代码集中在一个地方,提高了代码复用性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 

The ATLMacros sample demonstrates using the new ATL macros OBJECT_ENTRY_AUTO. This replaces the BEGIN_OBJECT_MAP/OBJECT_ENTRY/END_OBJECT_MAP combination.

The sample is based on the ATL Project created by the AppWizard. If you choose to follow the steps in this document to create your own application, then ensure that in the Application settings dialog you choose 'DLL project' and you must ensure that you uncheck the 'Attributed' checkbox, otherwise the code will be created using the new C++ Attributes for the COM classes.

In VC6 the Object Map BEGIN_OBJECT_MAP/END_OBJECT_MAP was used to list all the ATL classes in the server that implemented COM classes. The Object Map was located in the server .cpp file (where WinMain() or DllMain() functions were located). To add a class to the map, the OBJECT_ENTRY macro was used. Object Maps provides support for the registration, initialization, and creation of a class.

In VC7 the OBJECT_ENTRY_AUTO macro is used for this instead.

Syntax:

OBJECT_ENTRY_AUTO(clsid, class )

Parameters:

clsid [in]   The CLSID of a COM class implemented by the C++ class named class.
class [in]   The name of the C++ class implementing the COM class represented by clsid.

So now there is no Object Map. You simply place the object entry macros at global scope in the project and it does all the work for you. The AppWizard puts this macro to the end of the ATL class header file, so you have all your class code in one place. Previously (VC6) it was easy to forget to add a class to the Object Map. Now you have all your code in one place, so it is easy to reuse existing classes since you can just copy the files that implement it and add them to the project. No more messing around with OBJECT_ENTRY macros.

The Sample Application

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值