[Lazarus] String vs WideString

Marcos Douglas B. Santos md at delfire.net
Sat Aug 12 21:46:09 CEST 2017


Hi,

I have a "old" system that was coded in FPC 2.6.5.
Today I had to change something in the code and now I need to update
to FPC 3.0 and Lazarus 1.9.

This system uses a COM object. I made a class to wrap the configuration.

So, all string arguments in this class is WideString based.
The SetLicence method will receive a WideString but the source is a "string".

Look:

    Lib.SetLicense(
      IniFile.ReadString('TheLib', 'license', '')
    );

As you know, IniFile.ReadString returns a "string" and some internal
conversion is happening and the licence is not valid anymore.

If I put the licence as a string directly, it works:

    Lib.SetLicense(
      'my_licence_here'
    );

How can I change my code to work properly using Ini files, strings and
WideString?

Best regards,
Marcos Douglas


More information about the Lazarus mailing list