I found ComClass, now how do I do it?

I wrote a small COM server in Delphi 2010 that acts as a plugin in a retail application. The trading application looks for a "discover" interface that registers any number of additional interfaces that call TAutoObjectFactory.Create

for each one. This works great - all pluggable interfaces function as designed.

But now I would like to call a public method of one interface from another interface, so I don't need to duplicate code. Seems simple enough, just call ComClassManager.ForEachFactory

looking for the ClassID of the interface I need to use. Got it too!

But now that I have found the class, I am puzzled by the seemingly trivial last step: how to use or distinguish a class (or a class reference?) That I found in order to actually call one of its methods.

In the "FactoryProc" I posted to ForEachFactory

, I am assuming the ComClass property for TComObjectFactory

is what I need, but it is a TClass type, a class reference to the actual class object it is (at least I hope I understand correctly ). I am a bit fuzzy about class references and my attempts to reset or otherwise remove the reference to this property resulted in access violations or compiler errors.

Any suggestions?

+3


source to share


1 answer


You are correct in your comment, ComClassManager

deals with classes, not instances. What you need (your local application implementation) is a working object table (or something similar) so the plugin instances can communicate with each other.



How to actually implement this depends on what you really need, for example. calling methods for all running instances or only for instances of certain classes.

+3


source







All Articles