[Overview][Constants][Types][Classes][Procedures and functions][Variables][Index] | Reference for unit 'Variants' (#rtl)

# GetPropValue

Return a property value as a variant

## Declaration

Source position: variants.pp line 345

`function GetPropValue(`
`Instance: TObject;`
`PropInfo: PPropInfo;`
`PreferStrings: Boolean`
`):Variant; overload;`

## Arguments

`Instance` |  | Instance from which to get property value
`PropInfo` |  | Pointer to propety information (RTTI)
`PreferStrings` |  | Try to cast to string

## Function result

Property value as variant

## Description

GetPropValue returns the value of the property described by PropInfo from the Instance. The property value is returned as a variant type.

when PreferStrings is true, the implementation will tend to cast to a string-valued variant when a conversion must be done.

This function is used as the value for the TypInfo unit's OnGetPropValue callback. This callback is automatically initialized with the function when the variants unit is used.

## See also

TypInfo |  | Access Run-Time Type Information (RTTI)
TypInfo.OnGetPropValue |  | Callback to get a property value as a variant.
SetPropValue |  | Set a property value as a variant