Discussion:
The "Proper" way for storing app data
(too old to reply)
Bryan
2007-05-21 19:23:40 UTC
Permalink
Hi all,

I'm at a crossroads about how I should save my application data (database, images, config files etc...)...basically any file that needs to be able to change.

I've been hearing rumors that Vista locks down the pc so tight that users cannot save any data anywhere within the "Program Files" group without admin rights.

If this is the case, what is the "Best Practice" solution.

Thanks for all suggestions.

Regards,
Bryan
Lars Frische
2007-05-22 11:04:02 UTC
Permalink
Hi Bryan,

This works for me:

function GetAppDataPath: string;
var path: PChar;
begin
result := '';
GetMem(path, 255);
try
if SHGetSpecialFolderPath(Application.Handle, path, CSIDL_APPDATA ,
false) then
begin
result := StrPas(path) +
'\'+ChangeFileExt(ExtractFileName(Application.ExeName), '')+'\';
ForceDirectories(result);
end;
finally
FreeMem(path);
end;
end;

Cheers

Lars
--
Lars Frische
Software Developer
Test Maschinen Technik GmbH
Germany

===
http://www.eddyMax.com
http://www.kontrolltechnik.com
Loading...