轉(zhuǎn)自:http://msdn.microsoft.com/zh-cn/library/4tc639ss(VS.80).aspx
可以更改基于 ATL 的 COM 對(duì)象的屬性,使客戶端不能直接創(chuàng)建該對(duì)象。這種情況下,將通過(guò)另一對(duì)象上的方法調(diào)用返回對(duì)象,而不是直接創(chuàng)建對(duì)象。
使對(duì)象不可創(chuàng)建
-
移除對(duì)象的 OBJECT_ENTRY_AUTO。如果希望對(duì)象不可創(chuàng)建而控件能注冊(cè),則用 OBJECT_ENTRY_NON_CREATEABLE_EX_AUTO 替換 OBJECT_ENTRY_AUTO。
-
在 .idl 文件中向 coclass 添加 noncreatable 屬性。例如:
[
uuid(A1992E3D-3CF0-11D0-826F-00A0C90F2851),
helpstring("MyObject"),
noncreatable
]
coclass MyObject
{
[default] interface IMyInterface;
}
posted on 2009-01-14 09:23
鹿哥 閱讀(275)
評(píng)論(0) 編輯 收藏 引用 所屬分類(lèi):
COM