Using Delphi, how do I access the equivalent of .NET’s System.Environment.SpecialFolder.LocalApplicationData variable (which works on any version of Windows)? I assumed I could just do:
dir := GetEnvironmentVariable('LOCALAPPDATA');
This works on Vista but XP doesn’t seem to set that environment variable by default at least on my test machine.
In Delphi, the special system folder path constants are defined in ShlObj.DCU, and are referenced in the form of CSIDL_ followed by a symbolic name. Example:
Here’s a quick function that will return the appropriate special folder path when given the symbolic name. Make sure you include the SHLOBJ.DCU unit in your USES statement, and use the following:
================================================================
For reference, the constants are as follows: