Am 15.03.2011 15:24, schrieb Peter Williams:
Hi Bart,

 > Date: Tue, 15 Mar 2011 12:45:49 +0100
 > From: [email protected]
 > To: [email protected]
 > Subject: Re: [Lazarus] Unable to rewrite .ini file which exists...
error unable to create .ini file. (need to rewrite it).
 >
 > On 3/15/11, Peter Williams <[email protected]> wrote:
 >
 > > ConfigIni :=
TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));
 >
 > You really should not do that in most OS's, even on Windows it is
 > deprecated since win9x.
 > Most times you will not have write permissions there.
 > Also under *nix this location might not be what you expect it to be...
 >
 > Use GetAppConfigDir to determine where to put INI files.

I found the declaration for function GetAppConfigDir in osutilsh.inc but
I cannot find the actual function (I am looking in the wrong file).


If you search the function by clicking on the identifier in Lazarus while pressing "Ctrl" you should be able to use "Ctrl + Shift + Down" to find the declaration.

Alternatively you can search the directory "%lazarus%\fpc\%version%\rtl" to find the implementation (might be some file in the win or win32 directory).

Function GetAppConfigDir(Global : Boolean) : String;
Function GetAppConfigFile(Global : Boolean) : String;
Function GetAppConfigFile(Global : Boolean; SubDir : Boolean) : String;

What is the "Global : Boolean" parameter that it takes? Can someone
please give me an example as to how it is called?

If global is true the system's configuration directory is returned, if false the current user's directory.

E.g.:

Windows 7:
GetAppConfigDir(True):
C:\ProgramData\AppName
GetAppContigDir(False):
C:\Users\Sven\AppData\Local\AppName (or Roaming, I haven't tested, to be honest)

Linux:
GetAppConfigDir(True):
/etc/AppName
GetAppConfigDir(False):
/home/sven/.config/AppName

When you use GetAppConfigFile instead, AppName.cfg is returned instead of AppName.

See also:
http://www.freepascal.org/docs-html/rtl/sysutils/getappconfigdir.html
http://www.freepascal.org/docs-html/rtl/sysutils/getappconfigfile.html

Regards,
Sven

--
_______________________________________________
Lazarus mailing list
[email protected]
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply via email to