1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52
|
procedure TForm1.Button1Click(Sender: TObject);
var
myZipFile: TEncryptedZipFile;
DecompStream: TStream;
HeadZip: TZipHeader;
myBytes: TBytes;
tListFile: tStringList;
nIdx, nCptComp, nCptUncComp: Integer;
begin
Memo1.Clear;
nCptComp := 0;
nCptUncComp := 0;
tListFile := tStringList.Create;
ZipListPrg(sFileName, tListFile); { List of Include Files in Zip }
if tListFile.Count > 0 then
begin
myZipFile := TEncryptedZipFile.Create(sPassword);
myZipFile.Open(sFileName, TZipMode.zmRead);
for nIdx := 0 to tListFile.Count - 1 do
begin
// Read Zip include Files
myZipFile.Read(nIdx, DecompStream, HeadZip);
Memo1.Lines.Add('-------------------------');
Memo1.Lines.Add(tListFile[nIdx] + '(' + intToStr(nIdx) + ')');
nCptComp := nCptComp + HeadZip.CompressedSize;
Memo1.Lines.Add('CompressedSize : ' + intToStr(HeadZip.CompressedSize) + '/ Total : ' + intToStr(nCptComp));
nCptUncComp := nCptUncComp + HeadZip.UncompressedSize;
Memo1.Lines.Add('UncompressedSize : ' + intToStr(HeadZip.UncompressedSize) + '/ Total : ' +
intToStr(nCptUncComp));
Memo1.Lines.Add('-------------------------');
// Load Stream
setLength(myBytes, HeadZip.UncompressedSize);
try
DecompStream.Read(myBytes, 0, HeadZip.UncompressedSize);
except
on EReadError do
//ShowMessage('Read Error !!');
end;
DecompStream.Free;
Memo1.Lines.Add(TEncoding.UTF8.GetString(myBytes));
end;
end;
tListFile.Free;
end; |