|
|
COM Objects in Delphi, Part 1
Satellites and Containers
Continued from COM object essentials
The key to creating COM objects with multiple interfaces with Delphi involves treating the COM object as a container for its interfaces. A COM object does not have to be every interface object that it supports. It simply must supply the interface on demand, when the QueryInterface function of its IUnknown interface is called. The Delphi-based COM object handles the three IUnknown functions directly and returns a pointer to itself when the IUnknown interface is requested via QueryInterface. It acts as a container and manager of other objects that implement other interfaces. The satellite interface objects "reflect" the three IUnknown functions to their container. When a request arrives for one of the satellite interfaces (as usual, via QueryInterface) the container returns a pointer to the satellite object. Figure 1 shows the Delphi implementation of the satellite and container types of interface objects, along with a corresponding IClassFactory interface.
Continues...
Published as Power Programming in the 01/07/97 issue of PC Magazine.
|