COM Objects and Class Factories

In addition to supporting one or more interfaces that descend from IUnknown and implementing reference counting for lifetime management, COM objects also have another special feature: They are created through special objects called class factories. Each COM class has an associated class factory that's responsible for creating instances of that COM class. Class factories are special COM objects that support the IClassFactory interface. This interface is defined in the ActiveX unit as follows:

 type IClassFactory = interface(IUnknown) ['{00000001-0000-0000-C000-000000000046}'] function CreateInstance(const unkOuter: IUnknown; const iid: TIID; out obj): HResult; stdcall; function LockServer(fLock: BOOL): HResult; ...

Get Borland® Delphi™ 6 Developer's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.