Delphi XE

uses System.IOUtils;

procedure TForm1.btn3Click(Sender: TObject);
var
  S: string;
begin
  { 三种方法结果一致: C:UsersAdministratorAppDataRoaming }
  S := GetHomePath;     // SysUtils, 能跨平台且简单, 在 Windows 下使用 SHGetFolderPath 完成
  mmo1.Lines.Add(S);
  S := TPath.GetHomePath;                 // System.IOUtils
  S := GetEnvironmentVariable('APPDATA'); // 以前一直用这个
end;
原文地址:https://www.cnblogs.com/redhat588/p/12821279.html