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'
}
}
}
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
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'
}
}
}
And lo and behold, my CoCreateInstance call no longer hung, and I was able to properly retrieve a pointer to an ITest interface.
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?
I'm using Visual Studio 2010.