Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-05

GetAppConfigDir problem

8 messages · 4 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Lee Jenkins

On Windows, this method returns the application's directory. IMO, this is wrong since its customary to install applications in the Program Files directory and with tighter locked down XP/2000 and DEFINITELY Vista, this is a problem since you are not usually given permission to write in these destinations now.

I think the GetSpecialDir method should be called (as it is with when the "Global" flag is false) with parameter CSIDL_COMMON_DOCUMENTS.

Reported:
http://bugs.freepascal.org/view.php?id=11257

Warm Regards, Lee

Reply by email

Lee Jenkins
to Lee Jenkins
Lee Jenkins wrote 11 lines
On Windows, this method returns the application's directory. IMO, this is wrong since its customary to install applications in the Program Files directory and with tighter locked down XP/2000 and DEFINITELY Vista, this is a problem since you are not usually given permission to write in these destinations now. I think the GetSpecialDir method should be called (as it is with when the "Global" flag is false) with parameter CSIDL_COMMON_DOCUMENTS. Reported: http://bugs.freepascal.org/view.php?id=11257

As a follow up, can anyone suggest how I could access the GetSpecialDir from outside sysutils.pas? I've tried it and it seems that its not in the interface section or I think think this is the case. I get a little confused with the includes.

Hope everyone had a good weekend.

Thanks,

Warm Regards, Lee "When my company started out, we were really, really, really, really small. Now...we're just really small."

Reply by email

Graeme Geldenhuys
to Lee Jenkins: On Windows, this method returns the application's directory. IMO, this is wrong since…

Hi Lee,

2008/5/5 Lee Jenkins :

On Windows, this method returns the application's directory. IMO, this is wrong since its customary to install applications in the Program Files directory and with tighter locked down XP/2000 and DEFINITELY Vista, this is a problem since you are not usually given permission to write in these destinations now.

I thought GetAppConfigDir () returns the '\documents and settings\<profile>\application data\<appname> path? Specifying the global parameter would return: '\documents and settings\all users\application data\<appname>'

Am I mistaken? The above behaviours should work just fine for locked down NT/Win2000 systems and Vista with UAC enabled, because the user should have write access to there profile directory.

Regards,
- Graeme -

_______________________________________________
fpGUI - a cross-platform Free Pascal GUI toolkit
http://opensoft.homeip.net/fpgui/

Reply by email

Lee Jenkins
to Graeme Geldenhuys
Graeme Geldenhuys wrote 18 lines
Hi Lee, 2008/5/5 Lee Jenkins : > On Windows, this method returns the application's directory. IMO, this is wrong > since its customary to install applications in the Program Files directory and > with tighter locked down XP/2000 and DEFINITELY Vista, this is a problem since > you are not usually given permission to write in these destinations now. I thought GetAppConfigDir () returns the '\documents and settings\<profile>\application data\<appname> path? Specifying the global parameter would return: '\documents and settings\all users\application data\<appname>' Am I mistaken? The above behaviours should work just fine for locked down NT/Win2000 systems and Vista with UAC enabled, because the user should have write access to there profile directory.

GetAppConfigDir returns the user's local folder when you specify false as the global parameter, but when you you specify true, it returns the application's directory.

From SysUtils.pas:

Function GetAppConfigDir(Global : Boolean) : String;
begin
   If Global then
     Result:=DGetAppConfigDir(Global) // or use windows dir ??
   else
     begin
     Result:=GetSpecialDir(CSIDL_LOCAL_APPDATA)+ApplicationName;
     If (Result='') then
       Result:=DGetAppConfigDir(Global);
     end;
end;
Warm Regards, Lee "When my company started out, we were really, really, really, really small. Now...we're just really small."

Reply by email

Lee Jenkins
to Lee Jenkins: As a follow up, can anyone suggest how I could access the GetSpecialDir from outside…
Lee Jenkins wrote 18 lines
Lee Jenkins wrote: > On Windows, this method returns the application's directory. IMO, this is wrong > since its customary to install applications in the Program Files directory and > with tighter locked down XP/2000 and DEFINITELY Vista, this is a problem since > you are not usually given permission to write in these destinations now. > > I think the GetSpecialDir method should be called (as it is with when the > "Global" flag is false) with parameter CSIDL_COMMON_DOCUMENTS. > > Reported: > http://bugs.freepascal.org/view.php?id=11257 > As a follow up, can anyone suggest how I could access the GetSpecialDir from outside sysutils.pas? I've tried it and it seems that its not in the interface section or I think think this is the case. I get a little confused with the includes.

I just went ahead and accessed the shfolder unit like so in case anyone else has a need to do this before the issue is addressed:

uses
shfolder
;

// .. etc, etc.
function GetSpecialFolderPath(folder : integer) : string;
const
   SHGFP_TYPE_CURRENT = 0;
var
   path: array [0..MAX_PATH] of char;
begin
   if SUCCEEDED(SHGetFolderPath(0,folder,0,SHGFP_TYPE_CURRENT, at path[0])) then
     Result := path
   else
     Result := '';
end;
procedure SaveMyFile(AStringList: TStringList);
var
   lPath: string;
begin
   lPath := GetSpecialFolderPath(CSIDL_COMMON_DOCUMENTS);
   lPath := lPath + PathDelim + 'AFile.txt'
   AStringList.SaveToFile(lPath);
end;

Of course, in my actual code its IFDEF'd to use GetAppConfigDir when linux/unix instead of the above function.

Warm Regards, Lee "When my company started out, we were really, really, really, really small. Now...we're just really small."

Reply by email

Michael Van Canneyt
to Lee Jenkins: On Windows, this method returns the application's directory. IMO, this is wrong since…
Lee Jenkins wrote 5 lines
On Windows, this method returns the application's directory. IMO, this is wrong since its customary to install applications in the Program Files directory and with tighter locked down XP/2000 and DEFINITELY Vista, this is a problem since you are not usually given permission to write in these destinations now.

If you are using the global flag, this implies usually read-only: it is meant to access global installation configuration settings, comparable to /etc in Linux/Unix.

The main problem is that the Windows directory structure has become so convoluted these days that one directory IMHO is as good as the next.

If you know a good Microsoft document describing where application files are meant to go, I'll be glad to have a look at it and maybe change the behaviour.

Michael.

Reply by email

Bart
to Michael Van Canneyt

Hi,

Michael Van Canneyt wrote 5 lines
If you know a good Microsoft document describing where application files are meant to go, I'll be glad to have a look at it and maybe change the behaviour.

See for example: http://support.microsoft.com/kb/310294/en-us the section Classify
Application Data.
This would suggest to me that CSIDL_COMMON_APPDATA would be the most logical place to store global application data like /etc/ on Linux. I'm not sure that this is Win9x compatible, will check that when I have time.

Bart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080507/37145020/attachment.html

Reply by email

Bart
to Bart
Bart wrote 9 lines
See for example: http://support.microsoft.com/kb/310294/en-us the section Classify Application Data. This would suggest to me that CSIDL_COMMON_APPDATA would be the most logical place to store global application data like /etc/ on Linux. I'm not sure that this is Win9x compatible, will check that when I have time.

Just wrote som etest code. On Win9x using CSIDL_COMMON_APPDATA returns: Global: C:\WINDOWS\All Users\Application Data\
Local : C:\WINDOWS\Application Data\
(on my machine (WinME, not using profiles), so this would seem safe to use.

Bart
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.lazarus.freepascal.org/pipermail/lazarus/attachments/20080507/43d70b3d/attachment.html

Reply by email