Reputation: 4305
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!
Upvotes: 1
Views: 2123
Reputation: 13312
In RAR.pas:
fFileName
field and the Filename
property to WideString.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.
Upvotes: 2
Reputation: 24096
If I look at the sourcecode that you just linked to, I think you didn't have to change anything. It looks like it should already support unicode. The author claims it's for Delphi 2009, I see that there are two versions of TRarProcessFile():
TRARProcessFile = function(hArcData: THandle; Operation: Integer; DestPath, DestName: PAnsiChar): Integer; stdcall;
TRARProcessFileW = function(hArcData: THandle; Operation: Integer; DestPath, DestName: PWideChar): Integer; stdcall;
TRARProcessFileW should accept a filename with Unicode characters. Did you try to use that?
Maybe it somehow still doesn't work (I haven't tried it myself with Unicode characters yet), but if this doesn't work, then maybe it's helpful if you describe what goes wrong with a bit more detail.
Oh, and just to be sure: you are using Delphi 2009+ right?
Upvotes: 1