ATL default registration class .rgs

I am creating a COM server executable and have encountered a problem registering classes. When I created the 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' } } } 

This correctly created registry entries for the CLSID. However, when I tried to call CoCreateInstance from the outside, I experienced a hang.

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

Looking at a few other projects as an example, I noticed that they all have registry entries like:

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

I examined .rgs files for these classes and noticed that they have additional entries that are not in my .rgs file. I added them to myself, 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' } } } 

And so, my call to CoCreateInstance no longer hung, and I was able to correctly find the pointer to the ITest interface.

Now, my question is, given the above features, how can I guarantee that any future classes that I create have this correct .rgs file format? Is there any parameter that I miss when creating class objects? Or do I need to manually add above for each class that I create?

I am using Visual Studio 2010.

+6
source share
2 answers

This is the progID for the class. It is mainly used for scripting languages ​​that use late binding. CreateObject () is the usual function name. That it has anything to do with hovering is inexplicable; it’s better to debug it.

The .rgs record is otherwise automatically created by the ATL wizard. The ProgID edit box is lower right. It does not fill up automatically, like everyone else, you probably missed it.

+6
source

I apologize for five years later ... I got a similar problem with the ATL COM wizard using Visual Studio 2015 pro. (error 0x80080005 - Server failed to complete) This is similar to an error in the ATL COM wizard (since some versions of VS are still not fixed on the latest VS2015).

I found the answer with manual correction on this MS page: https://connect.microsoft.com/VisualStudio/feedback/details/782281/catlservicemodulet-not-registering-components

The .rgs files are not completely populated by the wizard. Hope this helps.

+1
source

Source: https://habr.com/ru/post/886288/


All Articles