> Yes, that should work and is the bare minimum required for use
> in the demos. Though it cannot handle a possible BOM.
>   
With a little trick and we just need to rewrite the create constructor.

unit UnicodeIniFile;

interface
type
  TMyUnicodeIniFile = class(TIniFile)
  public
    constructor Create(const aFileName: string);
  end;

implementation
uses Classes, sysutils, Inifiles;

constructor TMyUnicodeIniFile.Create(const aFileName: string);
var f: TfileStream;
const UnicodeBOM: word = $FEFF;
begin
  if not fileexists(aFileName) then
  try
    f.Write(UnicodeBOM, 2);
  finally
    f.Free;
  end;
  inherited;
end;

end.

The D2009 TInitFile already uses the WritePrivateProfileStringW and 
GetPrivateProfileStringW versions of the functions, but only work if the 
ini file already exists and is Unicode. This code does the trick adding 
the Unicode BOM if files does not exist already.


-- 
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be

Reply via email to