System.TypInfo.GetPropValue

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function GetPropValue(Instance: TObject; const PropName: string;
PreferStrings: Boolean): Variant;
function GetPropValue(Instance: TObject; PropInfo: PPropInfo;
PreferStrings: Boolean): Variant;

C++

extern DELPHI_PACKAGE System::Variant __fastcall GetPropValue(System::TObject* Instance, const System::UnicodeString PropName, bool PreferStrings = true)/* overload */;

Properties

Type Visibility Source Unit Parent
function public
System.TypInfo.pas
System.TypInfo.hpp
System.TypInfo System.TypInfo

Description

Retrieves a component property value as a variant.

GetPropValue utilises Delphi's RTTI (Run Time Type Information) to retrieve a component property as a variant.

Typically, the Variant type cannot keep the types TObject, set, method pointer, and class. But GetPropValue and SetPropValue can handle these types. In these cases, the returned Variant value is only used by SetPropValue with the same property type. You should not use this returned Variant value for any other purpose.

If you want to get the Variant type property, you must use GetVariantProp instead of GetPropValue.

In one form of this function, the property of the object Instance is defined by a PropInfo record. GetPropInfo and GetPropList can be used to obtain such a record.

In the other form of this function, the name of the property, PropName, is explicitly given.

In both forms of the function, the value of the specified property is returned as a variant.

The PreferStrings parameter specifies whether string representation should be used when getting property values of types enumeration or set.

Note: If the specified property does not exist or is not a published property, an EPropertyError exception is raised.

See Also