In order to use the ID constants by name in the array declaration, you need to remove the TGuid
type from the ID constant declarations, making them "True constants" instead of "Typed constants":
const
FOLDERID_LocalAppData = '{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}';
FOLDERID_RoamingAppData = '{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}';
FOLDERID_Documents = '{FDD39AD0-238F-46AF-ADB4-6C85480369C7}';
{...}
This is covered in Embarcadero's documentation:
Declared Constants
True Constants
A true constant is a declared identifier whose value cannot change. For example:
const MaxValue = 237;
declares a constant called MaxValue
that returns the integer 237. The syntax for declaring a true constant is:
const identifier = constantExpression
where identifier
is any valid identifier and constantExpression
is an expression that the compiler can evaluate without executing your program.
...
Constant Expressions
A constant expression is an expression that the compiler can evaluate without executing the program in which it occurs. Constant expressions include numerals; character strings; true constants; values of enumerated types; the special constants True
, False
, and nil
; and expressions built exclusively from these elements with operators, typecasts, and set constructors.
...
Typed Constants
Typed constants, unlike true constants, can hold values of array, record, procedural, and pointer types. Typed constants cannot occur in constant expressions.
...
Array Constants
To declare an array constant, enclose the values of the elements of the array, separated by commas, in parentheses at the end of the declaration. These values must be represented by constant expressions.
It is often useful to declare typed constants as well, which you can do without repeating the values, eg:
const
FOLDERID_LocalAppData = '{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}';
FOLDERID_RoamingAppData = '{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}';
FOLDERID_Documents = '{FDD39AD0-238F-46AF-ADB4-6C85480369C7}';
{...}
FOLDERID_LocalAppData_GUID: TGUID = FOLDERID_LocalAppData;
FOLDERID_RoamingAppData_GUID: TGUID = FOLDERID_RoamingAppData;
FOLDERID_Documents_GUID: TGUID = FOLDERID_Documents;
{...}
settings_roots: array[0..2] of TGuid = (
FOLDERID_LocalAppData, FOLDERID_RoamingAppData, FOLDERID_Documents
);
Alternatively, so the TGuid
typed constants can match the Win32 API naming scheme:
const
FOLDERID_LocalAppData_STR = '{F1B32785-6FBA-4FCF-9D55-7B8E7F157091}';
FOLDERID_RoamingAppData_STR = '{3EB685DB-65F9-4CF6-A03A-E3EF65729F3D}';
FOLDERID_Documents_STR = '{FDD39AD0-238F-46AF-ADB4-6C85480369C7}';
{...}
FOLDERID_LocalAppData: TGUID = FOLDERID_LocalAppData_STR;
FOLDERID_RoamingAppData: TGUID = FOLDERID_RoamingAppData_STR;
FOLDERID_Documents: TGUID = FOLDERID_Documents_STR;
{...}
settings_roots: array[0..2] of TGuid = (
FOLDERID_LocalAppData_STR, FOLDERID_RoamingAppData_STR, FOLDERID_Documents_STR
);