Search code examples
delphiunicodecomponentsansirar

Delphi: make unicode RAR-component 2.0


I have RAR-component 2.0 and Delphi 2010. This component uses AnsiString for File Path. How can I make it unicode? I changed AnsiString to String in RAR.pas but it did not help.

Thanks!


Solution

  • In RAR.pas:

    • Change TRARArchiveInformation's fFileName field and the Filename property to WideString.
    • Change TRAR.OpenFile so the FileName argument is a WideString.
    • In TRAR.OpenArchive(Extract:boolean) change this line:

      ArcName := PAnsiChar(fArchiveInformation.FileName);

      to this:

      ArcNameW := PWideChar(fArchiveInformation.FileName);

    In RAR_DLL.pas:

    Change GetFileModifyDate so this line:

    h := OpenFile(PAnsiChar(FileName), Struct, OF_SHARE_DENY_NONE);
    

    is this:

    h := FileOpen(FileName, fmOpenRead or fmShareDenyNone);
    

    and remove the Struct: TOFSTRUCT; line from the var block.