COM注册什么时候需要注册APPID .

COM 7.0以后有这样一个宏DECLARE_REGISTRY_APPID_RESOURCEID

 

在VS03以后的版本中,ATL工程中会自动添加这样的代码

class CXXModule : public CAtlDllModuleT< CXXModule >
{
public :
 DECLARE_LIBID(LIBID_xinstallerLib)
 DECLARE_REGISTRY_APPID_RESOURCEID(IDR_XX, "{classid}")
};

CXXModule _AtlModule;

_CAtlDllModuleT继承自CAtlModule

 

看MSDN解释说AppId在DCOM中使用,主要是为了集中注册表中分散的属性值,觉得这个解释相当含糊。

 

那么什么时候才需要指定这个AppId呢?看到一个老外回答这个问题,不翻译了,原文看着比较好。

You need to specify an appid if one of the following is true:

  1. Your COM object is hosted in a service
  2. Your COM object has custom launch permissions
  3. Your COM object has custom access permissions
  4. You want to specify a default bitness for the COM server when launching an out-of-proc COM object. 
  5. Your COM object runs as another user
  6. Your COM object needs to run on another system (unless you specify a COSERVERINFO in your call to CoCreateInstanceEx)
  7. Your COM object needs to set the default authentication level (used if you don't call CoInitializeSecurity directly)
  8. Your COM object needs to specify the RPC endpoints for communication (or the TCP port number, etc)
  9. Your COM object should run on the same machine as the storage (ActivateAtStorage)
  10. Your COM object runs using the DLL surrogate
  11. Your COM object needs to set its software restriction trust level

If those are true, you need an appid, otherwise it's unnecessary (and takes up space on the disk).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值