我想从对象实例动态获取属性值。
我能够获取类属性、序数类型和字符串。 GetPropValue 的 delphi 源代码不支持 tkInterface。有没有办法使用属性信息获取接口。顺便说一句,所有公开的属性都是已发布的属性。
目前,我使用 TObject 作为返回类型。 GetPropValue 返回对象实例的地址。我将其类型转换为 TObject 并返回结果。
I want to dynamically get a property value from an object instance.
I was able to get the class properties, ordinal types and strings. The delphi source of the GetPropValue does not support tkInterface. Is there any way of getting the interface using the property info. BTW all the properties exposed are published properties.
for time being, i am using the TObject as the return type. GetPropValue returns the address of the object instance. I am typecasting that to TObject and returning the result.
发布评论
评论(1)
如果我理解正确,您想使用 GetInterfaceProp() 函数。用法与
GetPropValue()
相同,但它返回一个IInterface
,您可以使用支持()。If I understand you right you want to use GetInterfaceProp() function. Usage is same as
GetPropValue()
but it returns anIInterface
which you can "cast" to right type using ie Supports().