2

Using Delphi XE on Win7 x64, have Jedi Class Library ver. 3.45, and 7z.dll ver. 9.20,

Uses .., jclcompression;

procedure TForm1.Button1Click(Sender: TObject);
const
   an = 'C:\1.7z';
   fn = 'C:\1.txt';
var Arc: TJclCompressArchive;
    Ext: TJclCompressArchiveClass;

begin
   Ext := GetArchiveFormats.FindCompressFormat(an);
   Arc := Ext.Create(an);
   Arc.AddFile(ExtractFileName(fn), fn);
   Arc.Password:='123';

   // arc. .. compresslevel:= 0..9 (or store..ultra)
   // arc. .. compressmethod:= (lzma,lzma,bzip2,ppmd)
   // arc. .. dictionarysize:= (1 shl 1..30)
   // arc. .. comressheader:= true-false
   // arc. .. cryptalgorithm:= ??? aes256 only?
   // arc. .. threads:= 1..2
   // arc. .. cryptheader:= true-false

   Arc.Compress;

end;

How do I select the compression options shown above as comments with "//"?

Jedi documentation is practically nil, there can be someone faced such problem?

Tried some different versions of "job" with 7z: tSevenZip, SevenZipVcl, SevenZip Api, but has come to conclusion, that the freshest version for job with 7z.dll at project Jedi.

Warren P
  • 65,725
  • 40
  • 181
  • 316
Gu.
  • 1,947
  • 4
  • 30
  • 49

1 Answers1

7

The 7z specific parameters are implemented by TJcl7zCompressArchive class so thats what you have to use... try something like

Ext := GetArchiveFormats.FindCompressFormat(an);
if(Ext <> nil)and(Ext.InheritsFrom(TJcl7zCompressArchive))then begin
   Arc := Ext.Create(an);
   TJcl7zCompressArchive(Arc).SetCompressionLevel(9);
   TJcl7zCompressArchive(Arc).SetCompressHeader(True);
   ...
end;
ain
  • 22,394
  • 3
  • 54
  • 74
  • Thanks! Last question: how to change algorithm of compression on LZMA2 or PPMD (or about // arc. .. compressmethod:=(lzma,lzma,bzip2,ppmd))? – Gu. Dec 08 '11 at 10:18
  • Looks like the `TJcl7zCompressArchive` class doesn't support it... you could test does the `Arc` support `IJclArchiveCompressionMethod` interface and in case it does use it's `SetCompressionMethod` method (use `GetSupportedCompressionMethods` to determine which methods are supported by the archive format). – ain Dec 08 '11 at 10:52