- 人气:
- 放大
- 缩小
- 二维码
- 赞赏
delphi GetHomePath - 获取用户程序数据目录
delphi GetHomePath - 获取用户程序数据目录
uses System.IOUtils;
procedure TForm1.FormCreate(Sender: TObject);
var
S: string;
begin
{ 三种方法结果一致: C:\Users\wy\AppData\Roaming }
S := GetHomePath; // SysUtils, 能跨平台且简单, 在 Windows 下使用 SHGetFolderPath 完成
S := TPath.GetHomePath; // System.IOUtils
S := GetEnvironmentVariable('APPDATA'); // 以前一直用这个
end;
--------------------------------------------------------------------------------