Using Delphi 2007 I can write the following code:
interface
TTestType = (ttTest1, ttTest2);
procedure enumName;
var
EnumName: String;
begin
EnumName := GetEnumName(TypeInfo(TTestType), Ord(ttTest1));
end;
This compiles and works, EnumName contains 'ttTest1' at the end of the function.
However, when I change my TTestType to something like this:
interface
TTestType = (ttTest1=1, ttTest2=2);
My code suddenly won't compile anymore. [DCC Error] Test.pas(271): E2134 Type 'TTestType' has no type info
Now I can make a const array of string with the enum names, but I find this a dirty solution. Can anybody point me in the right direction or am I trying something impossible here?