Like this:
{$APPTYPE CONSOLE}
uses
System.TypInfo;
type
TMyClass = class
strict private
FMyValue: Integer;
published
property MyValue: Integer read FMyValue default 42;
end;
var
obj: TMyClass;
PropInfo: PPropInfo;
begin
obj := TMyClass.Create;
PropInfo := GetPropInfo(obj, 'MyValue');
Writeln(PropInfo.Default);
end.
Note that the class as it stands, just as is so for that in your question, is broken. The system will not automatically initialise properties to their default value when an instance is created. You would need to add a constructor to this class to do that.
defaultyou're using doesn't mean what you think it does. It's a storage specifier. It only decides whether or not the property is streamed to the DFM at designtime. (In this case, if theHTTPPortproperty is80when the .DFM is streamed, theHTTPPortproperty is not saved.) See the Storage Specifiers section: Note: Property values are not automatically initialized to the default value. That is, the default directive controls only when property values are saved to the form file...