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

查看:619
本文介绍了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调用不再hung,我能够正确地检索指向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天全站免登陆