TComObject = class(TObject, IUnknown, ISupportErrorInfo)
class PASCALIMPLEMENTATION TComObject : public System::TObject
TComObject is the base class for creating simple COM classes, such as those used for creating Shell extensions.
- A class identifier (CLSID) for external instantiation using a class factory.
- Optional support for aggregation implemented through the IUnknown methods.
- Support for the SafeCall calling convention and OLE exception-handling by implementing IProvideErrorInfo.
- Support for the the IErrorInfo mechanism.
TComObject can be used as a base class for creating classes for COM objects that must have a class identifier (CLSID). CLSIDs are used to register the class in the database registry and to externally instantiate the class using a class factory. The class factory for TComObject is TComObjectFactory. The class factory properties provide information about the TComObject class, such as its name, description, CLSID, and so on. The TComObjectFactory methods are used to register the TComObject class in the registry and to instantiate it.
TComObject can be instantiated either as a single COM object or as part of an aggregate. The IUnknown methods are implemented in TComObject to support aggregation by appropriately delegating to the controlling IUnknown interface when the instantiated COM object is the inner object of an aggregate. Consequently, for all interfaces that are implemented by the inner COM object, its reference count will not be directly affected when an interface reference is created.
TComObject supports the ISupportErrorInfo interface which allows OLE Automation controllers to query whether an error object will be available, and ensures that error information can be propagated correctly up the call chain. By implementing the ISupportErrorInfo interface method, InterfaceSupportsErrorInfo, TComObject supports the IErrorInfo mechanism, thereby providing support for OLE exception-handling and the safecall calling convention. The information available through the IErrorInfo interface is used for SafeCall error handling.
Using TComObject will not require the instantiated object to have a type library.