From RAD Studio API Documentation
Jump to: navigation, search


property RefCount: Integer read FRefCount;


__property int RefCount = {read=FRefCount, nodefault};


Type Visibility Source Unit Parent
property public
System.Win.ComObj TComObject


Indicates the number of references to the COM object that are currently in use.

RefCount is used to determine when the object can be destroyed. RefCount is the number of references to interfaces implemented by the COM object. When RefCount is zero, the object can be is destroyed.

RefCount is automatically incremented when references to interfaces implemented by the COM object are created, and is automatically decremented when those references are destroyed. RefCount is usually incremented by the IUnknown AddRef method and decremented by the IUnknown method, Release.

RefCount can be artificially incremented when a new object is created which may be passed as a function parameter. In this case, RefCount should not be zero, and should be incremented prior to the function call and decremented when the function returns.

Note: In Delphi code, the CreateFromFactory method artificially increment and decrements RefCount.

Note: In C++ code, if you pass a class factory to the constructor as the first parameter, the constructor artificially increments and decrements RefCount.

See Also