我可以创建和使用 COM 类而不在注册表中注册它吗? [英] Can I create and use a COM class without registering it in the registry?

查看:26
本文介绍了我可以创建和使用 COM 类而不在注册表中注册它吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要创建一个自定义 COM 对象,它最终看起来类似于:

I need to make a custom COM object that is going to end up looking similar to this:

static const GUID IID_ClientCommunicator = { 0x5219b44a, 0x874, 0x449e,{ 0x86, 0x11, 0xb7, 0x8, 0xd, 0xbf, 0xa6, 0xab } };
static const GUID CLSID_ClientCommunicator = { 0x5219b44b, 0x874, 0x449e,{ 0x86, 0x11, 0xb7, 0x8, 0xd, 0xbf, 0xa6, 0xab } };

class ATL_NO_VTABLE CClientCommunicator:
    public CComObjectRootEx<CComSingleThreadModel>,
    public CComCoClass<CClientCommunicator, &CLSID_ClientCommunicator>,
    public IDispatchImpl<CClientCommunicator, &IID_ClientCommunicator, 0, /*wMajor =*/ 1, /*wMinor =*/ 0>
{
public:
    //Custom functions

};

该对象最终将作为属性传递给 Internet Explorer 中的 window javascript 对象,以便我可以从 JavaScript 调用我在此类中定义的函数.

This object is going to end up being passed as a property to the window javascript object in internet explorer so that I can call the functions I define in this class from JavaScript.

我的问题是,如果这一切都在一个可执行文件中完成,我是否需要在注册表中注册 COM 对象?如果是,如果我的 COM 对象在可执行文件中,我该怎么做?

My question is, if this is all done in a single executable, do I need to register the COM object in the Registry? If yes, how do I do that if my COM object is in an executable?

推荐答案

正如用户@RaymondChen 在评论中指出的那样,有一个函数 CoRegisterClassObject here,可用于注册COM类,无需添加注册表.

As user @RaymondChen pointed out in the comments there is a function CoRegisterClassObject here, which can be used to register COM classes without needed to add them to the registry.

这当然只允许您在注册它的可执行文件范围内使用该 COM 类.

This of course only allows you to use that COM class in the scope of the executable which registered it.

这篇关于我可以创建和使用 COM 类而不在注册表中注册它吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆