I have a COM class (e.g., CLSID_WidgetFactory) that I want to make available to anyone in my process who calls:
CoCreateInstance(CLSID_Widget, ...);
But i want to make it available without having to register it, or include it in a registration-free COM assembly manifest.
Core question
I have:
- a
clsid(CLSID_Widget) - an
IClassFactoryimplementation
How can i register the these with the COM infrastructure so that anyone in my process can create the COM object?
Obviously I want to accomplish this:
- without registering the COM object in the
HKLM\Software\Classesregistry hive - without registering the COM object in the
HKCU\Software\Classeshive - without create a registration-free COM assembly manifest
Conceptually i would have my classID, and my factory object:
class WidgetFactory : ComObject, IClassFactory
{
//IClassFactory methods
HRESULT CreateInstance(IUnknown unkOuter, Guid iid, out obj)
{
Widget widget = new Widget();
HRESULT hr = widget.QueryInterface(iid, out obj);
return hr;
}
}
Then i want to register my class factory:
Guid CLSID_Widget = "{0677445E-EA9B-447A-AF2E-CCD86E49CED0}";
IClassFactory factory = new WidgetFactory();
RegisterClassFactory(CLSID_Widget, factory);
All that's left is to figure out how to register a COM Class in-memory:
void RegisterClassFactory(Guid clsid, IClassFactory classfactory)
{
//...
}
Search terms
- How to register a COM object in memory
- How to register a COM class in my process
- How to register a CLSID in memory
- How to register IClassFactory in my application
Note: I know the answer. But i can't figure out the correct set of search terms that would trigger a hit.
Bonus Reading