我要利用7-Zip Dll从德尔斐但没有能够找到体面的文件或例子。没有人知道如何使用7-Zip Dll从德尔菲?

有帮助吗?

解决方案

作为释放1.102的 绝地武士代码图书馆 支持 7-Zip 建成的 JclCompression 单元。没用它自然而,虽然。

其他提示

扩大在奥利弗吉森的答案,因为有很多绝地武士代码图书馆,我找不到任何体面的文件,但是这对我的作品:

uses
   JclCompression;

procedure TfrmSevenZipTest.Button1Click(Sender: TObject);
const
   FILENAME = 'F:\temp\test.zip';
var
   archiveclass: TJclDecompressArchiveClass;
   archive: TJclDecompressArchive;
   item: TJclCompressionItem;
   s: String;
   i: Integer;
begin
   archiveclass := GetArchiveFormats.FindDecompressFormat(FILENAME);

   if not Assigned(archiveclass) then
      raise Exception.Create('Could not determine the Format of ' + FILENAME);

   archive := archiveclass.Create(FILENAME);
   try
      if not (archive is TJclSevenZipDecompressArchive) then
         raise Exception.Create('This format is not handled by 7z.dll');

      archive.ListFiles;

      s := Format('test.zip Item Count: %d'#13#10#13#10, [archive.ItemCount]);

      for i := 0 to archive.ItemCount - 1 do
      begin
         item := archive.Items[i];
         case item.Kind of
            ikFile:
               s := s + IntToStr(i+1) + ': ' + item.PackedName + #13#10;
            ikDirectory:
               s := s + IntToStr(i+1) + ': ' + item.PackedName + '\'#13#10;//'
         end;
      end;

      if archive.ItemCount > 0 then
      begin
//         archive.Items[0].Selected := true;
//         archive.ExtractSelected('F:\temp\test');

         archive.ExtractAll('F:\temp\test');
      end;

      ShowMessage(s);
   finally
      archive.Free;
   end;
end;

Zip和7z没有问题,尝试Synopse:http://synopse.info/forum/viewtopic.php?pid=163

德尔菲现有司机、交叉平台拉链支持有TZipFile在XE2:

如何提取拉链文件TZipFile在德尔斐XE2和FireMonkey

如果你打算使用7Zip仅用于压缩和解压缩看看 TZip 组成部分。我已经写了一个小包装我自己的目的,你可以找到的 拉链。pas 文件,随时重复使用。

我试了很多方案和有问题,这一项工作。

下载 https://github.com/zedalaye/d7zip 复制7z.dll 和sevenzip.pas到项目diroctory和加sevenzip.pas到您的项目。

然后你可以用这个来解:

using sevenzip;

procedure Unzip7zFile (zipFullFname:string);
  var
    outDir:string;
  begin
    with CreateInArchive(CLSID_CFormat7z) do
    begin  
      OpenFile(zipFullFname);
      outDir := ChangeFileExt(zipFullFname, '');
      ForceDirectories (outDir);
      ExtractTo(outDir);
    end;
  end;

使用:

Unzip7zFile(ExtractFilePath(Application.ExeName) + 'STR_SI_FULL_1000420.7z');
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top