我想使用Delphi的7-Zip DLL,但一直没有找到像样的文档或示例。有谁知道如何使用德尔福的7-Zip DLL?使用德尔福的7-Zip?
回答
从版本1.102开始,JEDI Code Library支持7-Zip内置于JclCompression单元。尽管如此,我还没有使用过它。
如果您打算仅使用7Zip进行zip解压缩,请查看TZip组件。 我为自己的目的写了一个小包装,您可以在Zipper.pas文件中找到它,随时重复使用。
有很多绝地代码库的扩大对奥利弗·吉森的答案,因为,我无法找到任何像样的文档,但是这个工作对我来说:
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;
7邮编插件API
Zip和7z格式,没有DLL,尝试Synopse: http://synopse.info/forum/viewtopic.php?pid=163
它看起来不像Synopse支持7zip,只是zip。 – hikari 2014-09-19 13:06:28
德尔福现在有本地的,跨平台的ZIP支持与TZipFile在XE2:
How to extract zip files with TZipFile in Delphi XE2 and FireMonkey
链接已死亡。但是,这可能会有所帮助。 http://docwiki.embarcadero.com/Libraries/XE2/en/System.Zip.TZipFile – EMBarbosa 2013-01-09 16:16:44
我尝试了许多解决方案,并有问题,这一个工作。
下载https://github.com/zedalaye/d7zip 将7z.dll和sevenzip.pas复制到您的项目中,并将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');
- 1. 使用德尔福编辑CSS使用德尔福
- 2. 德尔福HID Delphi7和德尔福XE2
- 3. 德尔福v.Word - 如何从德尔福
- 4. 德尔福使用HIDController 2010
- 5. 德尔福使用Indy 10
- 6. 从德尔福使用wordpress
- 7. 德尔福:使用参数
- 8. DES_KEY_SZ德尔福
- 9. 德尔福Application.HintColor
- 10. 德尔福
- 11. 德尔福
- 12. 与德尔福
- 13. 德尔福
- 14. 德尔福:TRegExpr
- 15. 类德尔福
- 16. 德尔福的TQuery
- 17. 德尔福(dbExpress的)
- 18. 解决中的TDataSetProvider德尔福2010年或德尔福2009年
- 19. 德尔福:退出后的视频德尔福6
- 20. 德尔福自我指针的使用
- 21. 使用德尔福的Zabbix API
- 22. 德卡尔和德尔福2009年
- 23. 创建德尔福
- 24. 德尔福在Vista
- 25. 德尔福EOutOfResources(GDIError)
- 26. 解析德尔福
- 27. 在德尔福7
- 28. 消耗德尔福
- 29. NHibernate和德尔福
- 30. 德尔福7 __ArrayList
如果每个压缩对象将装入内存TZip工作正常。否则,你会陷入一片混乱。尝试制作一个300 MB的zip文件,然后将这些300 MB zip文件中的90个zip文件压缩成另一个带有TZip的zip文件,您将有一段有趣的时间。 – 2010-08-25 23:21:29