c0pyc4t c0pyc4t - 1 year ago 112
Ini Question

Borland BCB5 TInifile ignores Quotation Marks with Readstring()?

I am not quite familar with Borland C++ Builder 5 and am stuck with an issue.

I have an INI file with:


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 ")

Actual Output:

Ident1=myUser1 (without ")

While trying to debug this, I get a lot of Delphi system calls I dont know and cant find documentation for, like
, etc.

I was expecting some sort of
but was wrong.

Can somebody enlighten me on the problem, please?

Answer Source

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.