![]() |
![]() ![]() |
|
Container objects Continued from Satellite objects The IContainerUnknown object type is another direct descendant of IUnknown. It maintains its own reference count as a protected data field named FRefCount; the AddRef function increments FRefCount and the Release function decrements it. Both AddRef and Release return the new reference count; in addition, if the count has reached 0, the Release function frees the object. The DelphCOM unit also defines a global reference count for the entire DLL that contains descendants of the generic COM objects. The constructor and destructor of the container object increment and decrement, respectively, the global reference count. Every DLL that contains COM objects is required to supply two specific functions, DLLCanUnloadNow and DLLGetClassObject. DLLCanUnloadNow, implemented in the DelphCOM unit, returns False unless the global DLL reference count is 0. DLLGetClassObject will be specific to each DLL that relies on DelphCOM and can't be written until the COM objects (descendants of ISatelliteUnknown and IContainerUnknown) have been defined. The IContainerUnknown object responds to a QueryInterface request for the IUnknown interface by returning a pointer to itself. If any other interface is requested, it returns the error code E_NOINTERFACE. In a descendant of IContainerUnknown, the QueryInterface function will first call this inherited function. If the inherited method returns E_NOINTERFACE, the descendant will check the requested interface ID against the additional interfaces it supports, and return the satellite object that matches the request. Published as Power Programming in the 01/07/97 issue of PC Magazine. |
|
TOP | ![]() Copyright (c) 1997 Ziff-Davis Inc. |