I'm recently exploring how to use COM in c++ and come across with a simple ribbon code.
Code has:
HRESULT hr = CoCreateInstance(CLSID_UIRibbonFramework, NULL, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&g_pFramework));
So, it's based on COM, right? There should be some information about this component in Component Service, but I can't find it anyhow.
My question is how windows manages to find the COM component with corresponding CLSID provided in the header file(UIRibbon.h
)?
CoCreateInstance
:CoGetClassObject
:As MSDN says the lookup is transparent to caller and it embeds multiple sources: some CLSIDs might be explicitly registered by servers and are priority for lookup, then there is per-user registry of COM classes, machine wide registry, "Treat As" records etc.
Presumably, the most frequent scenario is the following. COM server (application or DLL) registers its CLSIDs with system registry as a part of its installation. Then system registry holds a record under
HKEY_CLASSES_ROOT
which holds information on specificCLSID
and how to locate code associated with it. ThenCoCreateInstance
and friends look this information up on caller request and do the magic letting the caller obtain callable interface pointer for the requested CLSID.This is in particular the case of
CLSID_UIRibbonFramework
, with its related information in registry underHKEY_CLASSES_ROOT\CLSID\{926749fa-2615-4987-8845-c33e65f2b957}
.