I am not quite familar with Borland C++ Builder 5 and am stuck with an issue.
I have an INI file with:
[Section1]
Ident1="myUser1"
Ident2=myPassword
I read the Username and Password values with this code:
{
auto_ptr<TIniFile> ifile(new TIniFile(myinifile));
AnsiString InternalUser= ifile->ReadString("Section1", "Ident1", "Defaultuser");
AnsiString InternalPassword= ifile->ReadString("Section1", "Ident2","Defaultpassword");
}
Here is the function declaration:
virtual AnsiString __fastcall ReadString(const AnsiString Section, const AnsiString Ident, const AnsiString Default);
Expected Output:
Ident1="myUser1" (with ")
Ident2=myPassword
Actual Output:
Ident1=myUser1 (without ")
Ident2=myPassword
While trying to debug this, I get a lot of Delphi system calls I dont know and cant find documentation for, like LStrToPChar
, LStrClr
, etc.
I was expecting some sort of Trim()
but was wrong.
Can somebody enlighten me on the problem, please?
This class is a wrapper around the long since deprecated Windows INI file API. The function that reads the values is GetPrivateProfileString
and its documentation says:
If the string associated with lpKeyName is enclosed in single or double quotation marks, the marks are discarded when the GetPrivateProfileString function retrieves the string.
Hence the behaviour that you observe.