我想使用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