You guys are overdoing it a bit. Delphi already stores sets in the form of flags (only difference is that it uses 16 bytes of memory instead of 4 byte dword), so all you need to do to get your flags is type cast the set to a dword like this:
Flags := LongWord(AnySet);
if you want this to work you will have to use enumeration range from 0 to 31 (type TMyEnum = (meOne, meTwo{these are fine}, meThrityThree = 32{this will be out of range for a dword})