如何使用TRttiProperty.setValue()设置“记录”值?

时间:2018-10-06 17:21:00

标签: delphi delphi-xe

如何使用TPoint设置TRttiProperty.setValue()属性的值?还是类型为record的其他任何属性?

2 个答案:

答案 0 :(得分:1)

我会这样:

default rel

extern printf
extern scanf
extern rand

section .rdata  ;; constants
    prompt: db "What is your guess? (Answer is: %d) ", 0
    congrats: db "You guessed it!", 10, 0

section .data   ;; mutable variables
    guess: dq 0
    target: dq 0    ; assumed constant, but technically not

section .text
    global main
main:
    stack_reserve: equ 40
    sub     rsp, stack_reserve

    ;; let's assign our random target
    ;; rand(num_target) % 100 + 1

    lea     rcx, [prompt]
    call    printf

    add     rsp, stack_reserve
    ret

答案 1 :(得分:1)

使用通用类方法TValue.From<>

Vertex: TPoint;
Val: TValue;
...
Vertex := Point(1, 22);
Val := TValue.From<TPoint>(Vertex);
Prop.SetValue(Self, Val);