procedure TForm1.Button1Click(Sender: TObject);
var
ZippedCount: Integer;
begin
with VCLZip1 do
begin
ZipName:= 'c:/test';
Password:= 'Simon.Hu';
Recurse:= True;
FilesList.Add('c:/dell.doc');
try
ZippedCount:= Zip;
MessageBox(
Handle,
PChar('压缩完毕! ' + #13 + '共压缩了 ' + IntToStr(ZippedCount) + ' 个文件。 '),
'提示',
MB_OK + MB_ICONINFORMATION
);
except
on E: Exception do
begin
MessageBox(
Handle,
PChar('压缩失败! ' + '失败原因:' + E.Message + ' '),
'错误',
MB_OK + MB_ICONERROR
);
Exit;
end;
end; //End Try
end; //End With
end;
procedure TForm1.Button2Click(Sender: TObject);
var
i:integer;
DestPath:String;
UnZippedCount:integer;
begin
with VCLUnZip1 do
begin
ZipName:= 'c:/test.zip';
Password:= 'Simon.Hu';
ReadZip;
for i:= 0 to Count - 1 do
Memo1.Lines.Add(Filename[i] + #9 + Pathname[i]);
DestPath:='c:/1';
DestDir:= DestPath;
DoAll:= True;
RecreateDirs:= True;
RetainAttributes:= True;
try
UnZippedCount:= UnZip;
MessageBox(
Handle,
PChar('解压完毕! ' + #13 + '共解压了 ' + IntToStr(UnZippedCount) + ' 个文件。 '),
'提示',
MB_OK + MB_ICONINFORMATION
);
except
on E: Exception do
begin
MessageBox(
Handle,
PChar('解压失败! ' + '失败原因:' + E.Message + ' '),
'错误',
MB_OK + MB_ICONERROR
);
Exit;
end;
end; //End Try
end; //End With
end;