RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
TCustomVariantType._AddRef Method

Responds when the caller acquires a reference to this object's interface.

Pascal
function _AddRef: Integer; stdcall;
C++
__fastcall __stdcall int _AddRef();

When an application uses an interface that is implemented by TCustomVariantType or one of its descendants, it automatically calls __AddRef. Typically, interfaced objects use the __AddRef method to increment a reference count, which is then decremented when the application releases the interface. In this typical scenario, when the reference count drops to zero, the object frees itself. 

TCustomVariantType implements its own version of the IInterface methods __AddRef and _Release that avoid this typical behavior. An application should have only a single instance of TCustomVariantType, and that instance should not be auto-freed when it is not in use. Thus, TCustomVariantType implements __AddRef so that it always returns –1. 

 

Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
What do you think about this topic? Send feedback!