3

I've written a small COM Server in Delphi 2010 that acts as a plug-in into a retail application. The retail application looks for a "discover" interface which registers any number of additional interfaces calling TAutoObjectFactory.Create for each one. This is working just fine--all the plug-in interfaces function as designed.

But now I'd like to call a public method of one interface from another interface so I don't have to duplicate code. Seems simple enough, just call ComClassManager.ForEachFactory looking for the ClassID of the interface I need to use. Got that working, too!

But now that I found the class, I'm stumped by a seemingly trivial final step: how to use or cast the class (or class reference?) I've located to actually call one of its methods.

In the "FactoryProc" I've sent to ForEachFactory, I assume the ComClass property of TComObjectFactory is what I'm after, but it's of type TClass, a class reference to the actual class object to which it points (at least I hope I'm understanding this correctly). I'm a little fuzzy on class references and my attempts to cast or otherwise de-reference this property has resulted in access violations or compiler errors.

Any suggestions?

Sertac Akyuz
  • 54,131
  • 4
  • 102
  • 169
David Cornelius
  • 437
  • 1
  • 5
  • 12
  • I'm starting to wonder if the ComClassManager has a list of class references but not the list of actual objects created at runtime. Perhaps that's why I keep getting access violations when I try to use the ComClass as an object. It is called "ComClassManager" not ComObjectManager after all... – David Cornelius Feb 19 '13 at 17:56

1 Answers1

3

You're right in your comment, ComClassManager deals with classes, not instances. What you need is (your application-local implementation of) running object table (or something similar), so plugin instances can interact with each other.

How to actually implement it depends on what you really need, e.g. call methods on all running instances, or only on instances of specific classes.

Ondrej Kelle
  • 36,941
  • 2
  • 65
  • 128