Sorry late reply.
Much appreciate your help, the GetString() Method still is not returning a string from the .INI file ?
I do have a small working sample if required ? showing no return value.
.ini files
.ini files
Hi Neale,
Yes, please send the sample to have a look, including both the ini file and the code you are using!
Yes, please send the sample to have a look, including both the ini file and the code you are using!
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
.ini files
IniFileSpec_Test is a XVIDE project using StdSDI as a framework, step through Function SetUpIni() and you will see the vars in the debug window, and the App_Paths.INI will be changed and updated. An empty App_Paths.INI is in IniFileSpec_Test directory.
.ini files
Hi Neale,
Ah right, I missed this method indeed. Thanks for the very good sample, here's an updated method code that you can use:
Ah right, I missed this method indeed. Thanks for the very good sample, here's an updated method code that you can use:
Code: Select all
METHOD GetString( cSection AS STRING, cEntry AS STRING, cDefault AS STRING ) AS STRING
LOCAL dwBytes AS DWORD
LOCAL cString AS STRING
IF SELF:_lFileExists
LOCAL p := String2Psz(Space(250)) AS PSZ
dwBytes := GetPrivateProfileString(String2Psz(cSection), String2Psz(cEntry), String2Psz(cDefault), p, 250, String2Psz(SELF:FullPath))
cString := Left(Psz2String(p), dwBytes)
ENDIF
RETURN cString
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu
.ini files
Thank you Chris, all good.
.ini files
Hi Chris,
would it not be better to use the .NET way of calling the functions?
I remember that I wrote that code with your help several years ago.
Wolfgang
would it not be better to use the .NET way of calling the functions?
Code: Select all
[DllImport("kernel32.dll",CharSet:=CharSet.Ansi,EntryPoint:="GetPrivateProfileString")];
static method GetString(lpAppName as string, lpKeyName as string, lpDefault as string, lpBuffer as StringBuilder, nSize as dword, lpFileName as string) as dword pascal
public virtual method GetString( cSection as string, cEntry as string, cDefault as string ) as string
local cReturn as string
local oReturn as System.Text.StringBuilder
oReturn := System.Text.StringBuilder{ _nStringLen }
IniFile.GetString( cSection, cEntry, cDefault, oReturn, dword( _nStringLen ), _cFileName )
cReturn := oReturn:ToString()
return cReturn
Wolfgang
Wolfgang Riedmann
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
Meran, South Tyrol, Italy
wolfgang@riedmann.it
https://www.riedmann.it - https://docs.xsharp.it
.ini files
Hi Wolfgang,
Yeah, absolutely! I just tried to adjust the code this time with the least possible amount of changes, but your way is definitely much more efficient!
Yeah, absolutely! I just tried to adjust the code this time with the least possible amount of changes, but your way is definitely much more efficient!
Chris Pyrgas
XSharp Development Team
chris(at)xsharp.eu
XSharp Development Team
chris(at)xsharp.eu