Forum > General

How find path to 'application data' in XP, 2k3, vista, 7 ?

(1/3) > >>

seba22:
Welcome,

I need to find patch for Application Data.

I have try that code:


--- Code: ---GetMem(P,128);
GetTempPath(144, P);
S := PChar(P);
app_data_path := Copy(S, 1, Length(S)-14);
FreeMem(P);
--- End code ---

On XP - c:\documents and settings\username 
On 7 - c:\users\name\AppData  - corect !

I didn't test it on any other OS :(


I need function what always return app data.

Any idea (including all languages).

Help, please :)

Regards

paweld:

--- Quote from: seba22 on May 13, 2010, 06:21:26 pm ---On 7 - c:\users\name\AppData  - corect !

--- End quote ---
not correct.
correct on win 7 - c:\users\name\appdata\roaming\

path for application data:

--- Code: ---GetEnvironmentVariable('appdata')
--- End code ---
or local application data:

--- Code: ---GetEnvironmentVariable('localappdata')
--- End code ---

for ms OS: 2000prof/2000server/xp/2003/vista/2008/7

Best regards / Pozdrawiam
paweld

Laksen:
There are a couple of related functions for this in SysUtils

GetAppConfigDir(false) is probably what you are looking for

seba22:

--- Quote from: paweld on May 13, 2010, 08:30:37 pm ---
--- Quote from: seba22 on May 13, 2010, 06:21:26 pm ---On 7 - c:\users\name\AppData  - corect !

--- End quote ---
not correct.
correct on win 7 - c:\users\name\appdata\roaming\

path for application data:

--- Code: ---GetEnvironmentVariable('appdata')
--- End code ---
or local application data:

--- Code: ---GetEnvironmentVariable('localappdata')
--- End code ---

for ms OS: 2000prof/2000server/xp/2003/vista/2008/7

Best regards / Pozdrawiam
paweld

--- End quote ---

Hello,

I just try and don't work. I can't find what parameter is missing...



--- Code: ---showmessage(GetEnvironmentVariable('localappdata'));
--- End code ---

It say's


--- Code: ---unit1.pas(424,40) Error: Wrong number of parameters specified for call to "GetEnvironmentVariable"
--- End code ---


Regards
PS: Witam rodaka ;)

JuhaManninen:

--- Quote from: seba22 on May 14, 2010, 08:02:47 am ---
--- Code: ---showmessage(GetEnvironmentVariable('localappdata'));
--- End code ---

It say's


--- Code: ---unit1.pas(424,40) Error: Wrong number of parameters specified for call to "GetEnvironmentVariable"
--- End code ---

--- End quote ---

Compiles and runs here. Parameters 'appdata' and 'localappdata' both return empty strings on my Linux.
GetAppConfigDir(false) returns a useful path. (as noted by Laksen).

Are you using Lazarus? You could easily check the required parameters for GetEnvironmentVariable() by Ctrl-Space. You can also check where your version of GetEnvironmentVariable() is defined by Ctrl-MouseClick. It may not be the SysUtils version.

Juha

Navigation

[0] Message Index

[#] Next page

Go to full version