Question

Usually, with Windows, I save my application's data in the user folder (%appdata%).

For that, I use the function ExpandEnvironmentStrings which is linked to Windows to get the folder I need, and I store inside a subfolder my inifile.

Is there any best practice to manage that and be compliant with all the supported platforms (Windows 32b, 64b & Mac)?


I successfully tested like that:

procedure TfrmMain.SaveSettings;
var
  fnINI: TFileName;
  ini  : TIniFile;
begin
  fnINI := IncludeTrailingPathDelimiter(GetHomePath) + IncludeTrailingPathDelimiter(APP_NAME) + ChangeFileExt(APP_NAME, '.ini');
  if ForceDirectories(ExtractFilePath(fnINI)) then
  begin
    ini := TIniFile.Create(fnINI);
    try
      ini.WriteString(INI_CONNECTION, INI_IP, edtIP.Text);
    finally
      ini.Free;
    end;
  end;
end;

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top