ATL COM 类注册 .rgs 文件默认值 [英] ATL COM class registration .rgs file defaults

查看:34
本文介绍了ATL COM 类注册 .rgs 文件默认值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在创建一个 COM 服务器可执行文件,但遇到了类注册问题.当我创建我的类对象时,自动生成的 .rgs 文件如下所示:

I'm creating a COM server executable, and have run into a problem with class registration. When I created my class object, the automatically generated .rgs file looked like this:

HKCR
{
    NoRemove CLSID
    {
        ForceRemove {4C6DAD45-64B4-4C55-81C6-4CE125226421} = s 'Test Class'
        {
            ForceRemove Programmable
            LocalServer32 = s '%MODULE%'
            {
                val ServerExecutable = s '%MODULE_RAW%'
            }
            TypeLib = s '{EAA173CA-BDBC-463A-8B7A-B010EFA467BC}'
            Version = s '1.0'
        }
    }
}

这正确地为 CLSID 创建了注册表项.但是,在尝试从外部调用 CoCreateInstance 时,我遇到了挂起.

This created the registry entries correctly for the CLSID. However, when attempting to call CoCreateInstance externally, I was experiencing a hang.

hr = CoCreateInstance( __uuidof(Test), NULL, CLSCTX_ALL, __uuidof(ITest), (void**)&pTest);

在查看了一些其他项目的示例后,我注意到它们都有以下类型的注册表项:

After looking at a few other projects for examples, I noticed that they all had registry entries of the type:

HKEY_CLASSES_ROOT<MODULE>.<CLASS>
HKEY_CLASSES_ROOT<MODULE>.<CLASS>CLSID

我调查了这些类的 .rgs 文件,并注意到它们有我的 .rgs 文件中不存在的额外条目.我将它们添加到我的,将其更改为:

I investigated the .rgs files for these classes, and noticed they had extra entries not present in my .rgs file. I added them to mine, changing it to:

HKCR
{
    TestModule.Test = s 'Test Class'
    {
        CLSID = s '{4C6DAD45-64B4-4C55-81C6-4CE125226421}'
    }

    NoRemove CLSID
    {
        ForceRemove {4C6DAD45-64B4-4C55-81C6-4CE125226421} = s 'Test Class'
        {
            ForceRemove Programmable
            LocalServer32 = s '%MODULE%'
            {
                val ServerExecutable = s '%MODULE_RAW%'
            }
            TypeLib = s '{EAA173CA-BDBC-463A-8B7A-B010EFA467BC}'
            Version = s '1.0'
        }
    }
}

您瞧,我的 CoCreateInstance 调用不再挂起,而且我能够正确检索指向 ITest 接口的指针.

And lo and behold, my CoCreateInstance call no longer hung, and I was able to properly retrieve a pointer to an ITest interface.

现在,我的问题是,考虑到上述细节,我如何确保我创建的任何未来类都具有正确的 .rgs 文件格式?创建类对象时是否缺少某些选项?还是我需要为我创建的每个类手动添加上述内容?

Now, my question is, with the above particulars in mind, how can I ensure that any future classes I create have this correct .rgs file format? Is there some option I'm missing when creating the class objects? Or will I need to manually add the above for every class I create?

我使用的是 Visual Studio 2010.

I'm using Visual Studio 2010.

推荐答案

那是 coclass 的 ProgID.它主要由使用后期绑定的脚本语言使用.CreateObject() 是常用函数姓名.这与挂起有什么关系是无法解释的,你最好调试一下.

That's the ProgID for the coclass. It is primarily used by scripting languages, the ones that use late binding. CreateObject() is the usual function name. That this has anything to do with a hang is unexplainable, you'd better debug it.

.rgs 条目否则会由 ATL 向导自动生成.ProgID 编辑框位于右下方.它不会像其他人一样自动填充,您可能错过了.

The .rgs entry is otherwise automatically generated by the ATL wizard. The ProgID edit box is the lower right one. It doesn't get filled in automatically like the rest of them, you probably missed it.

这篇关于ATL COM 类注册 .rgs 文件默认值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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