How to stop Delphi registering COM objects
Posted on 2003-02-20
I am writing a DLL in Delphi that serves COM objects to a Python script. Python is basically an interpreted language and accesses the COM objects using using IDispatch. As far as I can tell, the only way to write IDispatch objects in Delphi is to write dual-interfaced automation objects. I use File->New->ActiveX->Automation Object to create them because that's the only thing that seems to work for me.
Although the DLL provides many COM objects, I want the DLL to register only the top-level object (IServer). The python script makes calls on IServer to get the other objects, so no registration is necessary for them.
Unfortunately, when I create automation objects as above, Delphi adds a TAutoObjectFactory.Create to the initialization section for every unit. In consequence all the interfaces get registered. I can't comment out this bit because it causes TAutoObject.Create to fail. I suppose I could derive a new class factory from TAutoObjectFactor and the override the UpdateRegistry method to do nothing, but this seems ugly. Surely there is a better way.
So my question is this: Is there a proper way to serve IDispatch interfaces in Delphi without Delphi attempting to register them?