I'm an application packager trying to make sense of how the COM registry keys (SelfReg) interrelate to the given .dll in Windows.
ProgID's, AppID's, TypeLibs, Extensions & Verbs are all tied around the CLSID right? Do CLSID's always use Prog/App IDs or could you just have a file extension class? Which bits are optional?
Some of it seems to be 'like a router' where there's the two interfaces (internal - .dll) and external (the extension etc).
How does this all fit? (The SDK documentation doesn't make sense to me)
I ask as this is all pivotal to application 'healing' with Windows Installer (which packagers are all 'big' on, but there's no nitty-gritty breakdowns since its a coder-thing really)
---Edit: Am I safe in assuming that for what COM is registered, it must all link back to the CLSID and cannot be a 'dead-end'? Verbs need extensions which need progid's...
What about the AppId's, TypeLibs and Interfaces? How do they interrelate?
The Windows registry is a centralized, hierarchical database that manages resources and stores configuration settings for applications on the Windows operating system. Security account services, user interfaces, and device drivers can all use the Windows registry.
Your component will be registered into the Windows Registry so you need to figure out which hive you want to look in. If your component is installed with regasm, chances are HKCU will be used, since it will be run from a user's command line.
The registry maintains information about all the COM objects installed in the system. Whenever an application creates an instance of a COM component, the registry is consulted to resolve either the CLSID or ProgID of the component into the pathname of the server DLL or EXE that contains it.
You can run a command-line tool called the Assembly Registration Tool (Regasm.exe) to register or unregister an assembly for use with COM. Regasm.exe adds information about the class to the system registry so COM clients can use the . NET Framework class transparently.
The first thing to realise, is that COM dlls register themselves. They will put all the required entries into the correct places in the registry.
I think the answer to your central question about which bits are optional is probably that they are all optional for different types of objects. Automation objects require Prog/AppIDs if they are publicly creatable, but may not if they are only created internally, similarly a non- publicly creatable COM class can be listed.
Many COM objects that do not have automation interfaces (such as many of the COM classes microsoft uses internally in windows will not have any ProgId but will simply have an entry under their CLSID in HKCR\CLSID.
If I understand you correctly you are interested in this from a installer perspective. I would imagine that all you need do is ask the user to specify which dlls are selfregistering and then call
regsvr32 dllname.dll
or
exename.exe /Regserver
for a out of process server. If something goes wrong you just need to call the opposites.
regsvr32 /u dllname.dll
or
exename.exe /Unregserver
I hope that this answers your question.
I'd recommend the book Inside COM.
It wasn't the most up-to-date reference even during COM's heyday, but it explains the basics quite well, including all the registry goo. Plus, I bet you can get a used copy real cheap.
I know this isn't an answer, but remembering what the chapter about the registry looked like - a non-specific "how does it work" question will require a really, really long answer...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With