Quick start manual

11-12
Delphi Language Guide
Internal data formats
Variant types
A variant is stored as a 16-byte record that contains a type code and a value (or a
reference to a value) of the type given by the code. The System and Variants units
define constants and types for variants.
The TVarData type represents the internal structure of a Variant variable (on
Windows, this is identical to the Variant type used by COM and the Win32 API). The
TVarData type can be used in typecasts of Variant variables to access the internal
structure of a variable.
The VType field of a TVarData record contains the type code of the variant in the
lower twelve bits (the bits defined by the varTypeMask constant). In addition, the
varArray bit may be set to indicate that the variant is an array, and the varByRef bit
may be set to indicate that the variant contains a reference as opposed to a value.
The Reserved1, Reserved2, and Reserved3 fields of a TVarData record are unused.
The contents of the remaining eight bytes of a TVarData record depend on the VType
field. If neither the varArray nor the varByRef bits are set, the variant contains a value
of the given type.
If the varArray bit is set, the variant contains a pointer to a TVarArray structure that
defines an array. The type of each array element is given by the varTypeMask bits in
the VType field.
If the varByRef bit is set, the variant contains a reference to a value of the type given
by the varTypeMask and varArray bits in the VType field.
The varString type code is private. Variants containing a varString value should never
be passed to a non-Delphi function. On Windows, Delphi's Automation support
automatically converts varString variants to varOleStr variants before passing them as
parameters to external functions.
On Linux, VT_decimal is not supported.