Using 7-Zip from Delphi?

前端 未结 7 2348
醉梦人生
醉梦人生 2020-11-30 03:22

I would like to use the 7-Zip DLLs from Delphi but have not been able to find decent documentation or examples. Does anyone know how to use the 7-Zip DLLs from Delphi?

7条回答
  •  心在旅途
    2020-11-30 03:54

    I tried many solutions and had problems, this one worked.

    Download https://github.com/zedalaye/d7zip Copy 7z.dll and sevenzip.pas to your project diroctory and add sevenzip.pas to your project.

    Then you can use this to unzip:

    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;
    

    Usage:

    Unzip7zFile(ExtractFilePath(Application.ExeName) + 'STR_SI_FULL_1000420.7z');
    

提交回复
热议问题