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.