<html>
<head>
<style><!--
.hmmessage P
{
margin:0px;
padding:0px
}
body.hmmessage
{
font-size: 10pt;
font-family:Tahoma
}
--></style>
</head>
<body class='hmmessage'>
Hi,<br><br><hr id="stopSpelling">From: pewilliams2010@live.com<br>To: lazarus@lists.lazarus.freepascal.org<br>Date: Wed, 16 Mar 2011 01:24:46 +1100<br>Subject: Re: [Lazarus] Unable to rewrite .ini file which exists... error unable to create .ini file. (need to rewrite it).<br><br>
<meta http-equiv="Content-Type" content="text/html; charset=unicode">
<meta name="Generator" content="Microsoft SafeHTML">
<style>
.ExternalClass .ecxhmmessage P
{padding:0px;}
.ExternalClass body.ecxhmmessage
{font-size:10pt;font-family:Tahoma;}
</style>
<font class="ecxApple-style-span" face="Tahoma" size="2">Hi Bart,</font><br><br><div id="ecxSkyDrivePlaceholder" style="font-family:Tahoma;font-size:10pt"></div><font class="ecxApple-style-span" face="Tahoma" size="2">> Date: Tue, 15 Mar 2011 12:45:49 +0100</font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> From: bartjunk64@gmail.com</font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> To: lazarus@lists.lazarus.freepascal.org</font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> Subject: Re: [Lazarus] Unable to rewrite .ini file which exists... error unable to create .ini file. (need to rewrite it).</font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> </font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> On 3/15/11, Peter Williams <pewilliams2010@live.com> wrote:</font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> </font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> > ConfigIni := TIniFile.Create(ChangeFileExt(Application.ExeName,'.ini'));</font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> </font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> You really should not do that in most OS's, even on Windows it is</font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> deprecated since win9x.</font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> Most times you will not have write permissions there.</font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> Also under *nix this location might not be what you expect it to be...</font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> </font><br><font class="ecxApple-style-span" face="Tahoma" size="2">> Use GetAppConfigDir to determine where to put INI files.</font><div style="font-family:Tahoma;font-size:10pt"><br></div><div style="font-family:Tahoma;font-size:10pt">I found the declaration for function GetAppConfigDir in osutilsh.inc but I cannot find the actual function (I am looking in the wrong file).</div><div style="font-family:Tahoma;font-size:10pt"><br></div><div style="font-family:Tahoma;font-size:10pt"><div style="text-indent:0px !important;font-family:'Times New Roman';font-size:medium"><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent:0px !important">Function GetAppConfigDir(Global : Boolean) : String;</font></div><div style="text-indent:0px !important;font-family:'Times New Roman';font-size:medium"><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent:0px !important">Function GetAppConfigFile(Global : Boolean) : String;</font></div><div style="text-indent:0px !important;font-family:'Times New Roman';font-size:medium"><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent:0px !important">Function GetAppConfigFile(Global : Boolean; SubDir : Boolean) : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2" style="text-indent:0px !important"><br></font></div></div><div style="font-family:Tahoma;font-size:10pt">What is the "Global : Boolean" parameter that it takes? Can someone please give me an example as to how it is called?</div><div style="font-family:Tahoma;font-size:10pt"><br></div><div style="font-family:Tahoma;font-size:10pt"><br></div><div style="font-family:Tahoma;font-size:10pt"><br></div><div style="font-family:Tahoma;font-size:10pt">I just tried calling Str1 := GetAppConfigDir(true); ShowMessage(Str1);</div><div style="font-family:Tahoma;font-size:10pt"><br></div><div style="font-family:Tahoma;font-size:10pt">and my app is called Color_Life.exe and it returns "C:\ProgramData\Color_Life\". Since the folder "C:\ProgramData\" exists and it's subfolder "\Color_Life\" does NOT exist, then does this mean that I need to create it myself, or will my call to one of the "MemIniFiles" procedures create the folder for me?</div><div style="font-family:Tahoma;font-size:10pt"><br></div><div style="font-family:Tahoma;font-size:10pt">Best Regards,</div><div style="font-family:Tahoma;font-size:10pt"><span class="Apple-tab-span" style="white-space:pre"> </span>PEW</div><div style="font-family:Tahoma;font-size:10pt"><br></div><div style="font-family:Tahoma;font-size:10pt">Thanks,</div><div style="font-family:Tahoma;font-size:10pt">PEW</div><div style="font-family:Tahoma;font-size:10pt"><br></div><div style="font-family:Tahoma;font-size:10pt">osutilsh.inc ---</div><div style="font-family:Tahoma;font-size:10pt"><br></div><div><div><font class="ecxApple-style-span" face="Tahoma" size="2">{</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> This file is part of the Free Pascal run time library.</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> Copyright (c) 1999-2000 by Michael Van Canneyt</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> member of the Free Pascal development team</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> See the file COPYING.FPC, included in this distribution,</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> for details about the copyright.</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> This program is distributed in the hope that it will be useful,</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> but WITHOUT ANY WARRANTY; without even the implied warranty of</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> **********************************************************************}</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Type TExecuteFlags = Set of ( ExecInheritsHandles);</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">{ OS handling utilities }</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">{$ifdef HAS_OSERROR}</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function GetLastOSError : Integer;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">{$endif}</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Procedure RaiseLastOSError;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function GetEnvironmentVariable(Const EnvVar : String) : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function GetEnvironmentVariableCount : Integer;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function GetEnvironmentString(Index : Integer) : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">{$IFDEF HAS_SLEEP}</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">procedure Sleep(milliseconds: Cardinal);</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">{$ENDIF}</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">function ExecuteProcess(Const Path: AnsiString; Const ComLine: AnsiString;Flags:TExecuteFlags=[]):integer;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">function ExecuteProcess(Const Path: AnsiString; Const ComLine: Array of AnsiString;Flags:TExecuteFlags=[]):integer;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function GetTempDir(Global : Boolean) : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function GetTempDir : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function GetTempFileName(Const Dir,Prefix : String) : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function GetTempFileName : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">{ For windows compatibility }</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">function GetTempFileName(Dir,Prefix: PChar; uUnique: DWORD; TempFileName: PChar):DWORD;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function GetAppConfigDir(Global : Boolean) : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function GetAppConfigFile(Global : Boolean) : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function GetAppConfigFile(Global : Boolean; SubDir : Boolean) : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function GetUserDir : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function VendorName : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Function ApplicationName : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Const</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> ConfigExtension : String = '.cfg';</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> SysConfigDir : String = '';</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Type</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> TGetVendorNameEvent = Function : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> TGetAppNameEvent = Function : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> TGetTempDirEvent = Function (Global : Boolean) : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> TGetTempFileEvent = Function (Const Dir,Prefix : String) : String;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Type</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> TEventType = (etCustom,etInfo,etWarning,etError,etDebug);</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"><br></font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2">Var</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> OnGetVendorName : TGetVendorNameEvent;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> OnGetApplicationName : TGetAppNameEvent;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> OnGetTempDir : TGetTempDirEvent;</font></div><div><font class="ecxApple-style-span" face="Tahoma" size="2"> OnGetTempFile : TGetTempFileEvent;</font></div><div style="font-family:Tahoma;font-size:10pt"><br></div></div><div style="font-family:Tahoma;font-size:10pt">> <br>> Bart<br>> <br>> --<br>> _______________________________________________<br>> Lazarus mailing list<br>> Lazarus@lists.lazarus.freepascal.org<br>> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus<br></div>
<br>--
_______________________________________________
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus </body>
</html>