Setting a property value by name

In the Delphi class, I have some properties that I would like to set by accessing them by their name. Now I use, for example, Settings.AllowSysop := True;

What I would like to do something like Settings('AllowSysop').Value := True;

The reason for this is that when you configure that my users can access this, it is read from the license file, where the line read from the file (it looks like INI but is encrypted) can look like

 AllowSysop = True 

I know this is some kind of RTTI-like code that needs to be done, but I can't figure it out.

I think it would make it easier for me if it were possible.

Hope the explanation makes sense

+7
source share
1 answer
 implementation uses TypInfo; {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin if IsPublishedProp (Button1, 'Visible') then begin SetPropValue (Button1, 'Visible',false); end; end; 
+14
source

All Articles