Another solution to this problem, if you do not know the exact type of enumeration in your function, but instead TypeInfo, should use the TValue Make procedure.
procedure Make(AValue: NativeInt; ATypeInfo: PTypeInfo; out Result: TValue); overload; static;
( XML):
TRTTIField/TRTTIProperty.SetValue()
function EnumNameToTValue(Name: string; EnumType: PTypeInfo): TValue;
var
V: integer;
begin
V:= GetEnumValue(EnumType, Name);
TValue.Make(V, EnumType, Result);
end;
, .