Getting run time value of property of an object

Posted on 2005-04-29
Last Modified: 2010-04-05
So far, I've figured out how to generate a run time list of all the properties of an object, and what types they are, but I can't figure out how to get the actual value that the property is set to.

Here's the code I have so far.

procedure TComponentProperties.GetPropertyNameList(AObject: TObject;
  NameList: TStrings);
  i, PropCount : integer;
  PropList : PPropList;
  PropInfo : PPropInfo;
  TypeKinds : TTypeKinds;
  NewNameList : TStrings;

  TypeKinds := [tkInteger, tkChar, tkEnumeration, tkFloat, tkString, tkSet, tkClass, tkWChar,
                tkLString, tkWString, tkVariant,  tkArray,  tkRecord,  tkInterface,  tkInt64, tkDynArray];

  PropCount := GetPropList(AObject, PropList);
  GetMem(PropList, PropCount * SizeOf(PPropInfo));
    GetPropList(AObject.ClassInfo, TypeKinds, PropList);

    for I := 0 to PropCount - 1s do
      if PropList[i].PropType^.Kind = tkEnumeration then
       NameList.Add(FIndentString + PropList[i].Name + '=' + //CODE HERE TO DISPLAY VALUE OF PROPERTY);

That will produce a list of all the tkEnumeration property's...Any ideas on how to get the actual value of it?

Question by:kevinjd
    LVL 17

    Expert Comment


    Something like:

    NameList.Add(FIndentString + PropList[i].Name + '=' + IntToStr(GetOrdProp((AObject as TComponent), PropInfo))); //CODE ...

    Regards, Geo
    LVL 17

    Accepted Solution

    The last parameter was wrong. Try this way:

    NameList.Add(FIndentString + PropList[i].Name + '=' + IntToStr(GetOrdProp((AObject as TComponent), PropList[i])));

    Author Comment

    Thank you. That worked nicely.

    Featured Post

    Free Trending Threat Insights Every Day

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
    Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    20 Experts available now in Live!

    Get 1:1 Help Now