在 Delphi 类中,我想通过名称访问它们来设置一些属性。
现在我使用例如Settings.AllowSysop := True;
我想做一些类似的事情 Settings('AllowSysop').Value := True;
这样做的原因是,当设置我的用户可以访问的内容时,这是从许可证文件中读取的,其中从文件读取的行(它类似于 INI
但已加密)可能看起来像
AllowSysop = True
我知道必须编写一些类似于 RTTI 的代码,但我不太明白。
我认为如果可能的话,这对我来说会更容易一些。
希望解释有意义
最佳答案
implementation
uses TypInfo;
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if IsPublishedProp (Button1, 'Visible') then
begin
SetPropValue (Button1, 'Visible',false);
end;
end;
关于delphi - 按名称设置属性值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14352905/