delphi - डेल्फी से 7-ज़िप का उपयोग करना?
7zip (5)
मैं डेल्फी से 7-ज़िप डीएलएल का उपयोग करना चाहता हूं लेकिन सभ्य दस्तावेज या उदाहरण नहीं ढूंढ पा रहा हूं। क्या किसी को पता है कि डेल्फी से 7-ज़िप डीएलएल का उपयोग कैसे करें?
7 ज़िप प्लगइन एपीआई
ओलिवर गिसन के उत्तर पर विस्तार करते हुए, जेडीआई कोड लाइब्रेरी के साथ, मुझे कोई सभ्य दस्तावेज नहीं मिला, लेकिन यह मेरे लिए काम करता है:
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;
डेल्फी में अब XE2 में TZipFile के साथ देशी, क्रॉस प्लेटफ़ॉर्म ज़िप समर्थन है:
डेल्फी XE2 और FireMonkey में TZipFile के साथ ज़िप फ़ाइलों को निकालने के लिए कैसे करें
मैंने कई समाधानों की कोशिश की और समस्याएं थीं, यह एक काम किया।
https://github.com/zedalaye/d7zip अपनी परियोजना diroctory में 7z.dll और sevenzip.pas कॉपी करें और अपनी परियोजना में सातzip.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.102 JclCompression कोड लाइब्रेरी में JclCompression यूनिट में निर्मित 7-Zip लिए समर्थन है। हालांकि, अभी तक इसका इस्तेमाल नहीं किया है।