System.Variants.TCustomVariantType._AddRef

From RAD Studio API Documentation
Jump to: navigation, search


Delphi

function _AddRef: Integer; stdcall;

C++

int __stdcall _AddRef();

Properties

Type Visibility Source Unit Parent
function protected
System.Variants.pas
System.Variants.hpp
System.Variants TCustomVariantType

Description

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

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.

See Also