X-10 ActiveHome: Put your home on Auto-Pilot

PC Magazine

  PC Tech

COM Objects in Delphi, Part 1

Introduction

COM object essentials

Satellites and Containers

Satellite objects

Container objects

The Class Factory

GUIDs, CLSIDs, and IIDs

Figure 1

 
  Categories:
Programming
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.


 SPONSORED LINKS
Finance   Save now, save later - 9.99% Visa card - NOT an intro rate.
Shopping   Buy a 56K modem for $19.95 after rebate from NetMarket!
Software   X10.com -- The SuperSite for Home Automation
 ZDNET FEATURED LINKS
Freeware   It's a software free for all - 100 FREE downloads!
Contests   Enter to win a FREE multimedia PC from ZDNet!
 MAGAZINE OFFERS
Free Trial   Try the next issue of Computer Gaming World FREE!

TOP
Copyright (c) 1997 Ziff-Davis Inc.