When I register COM dll by running regsvr32 MyCOMdll.dll
in CMD I see several entries created in registry, one of them is:
[HKEY_CLASSES_ROOT\MyCOMdll.MyClass\Clsid]
@="{DB402D5A-5584-4F68-A750-45D3E8133121}"
I'd like to understand where DB402D5A-5584-4F68-A750-45D3E8133121
comes from, initially I thought that GUID generated at point when you register this DLL, however I checked this at different environments and I see it has same value. It looks like these GUIDs are embedded into DLL, but I cannot confirm or find out at which point.
Context: I want to perform a "hot swap" of that COM, however it doesn't seem to be straightforward. I tried to update GUIDs in registry after I register new DLL, but getting error ClassFactory cannot supply requested class
.
When you register a COM dll using regsvr32
, CLSIDs are defined inside the dll.
In typical ATL COM project, these entries are specified in *.rgs files, and registry is updated based on that content. Of course, this is not the only way to do it and other toolsets and technologies do it in different way.
These CLSIDs are actually defined in the .idl file of the project (again, this is valid for ATL projects), and .rgs file must correctly match the values. The .idl file itself contains IDL definitions of all COM types in the library, and is used by MIDL compiler to generate the type library.