tools->library->library path 中加上VCLUnZip的路径然后uses
给你一个加密文件的函数,参数为文件名,路径
function ZipToFile(FileName:string;FileDir:string):boolean;
var
VCLUnZip1: TVCLUnZip;
begin
Result := False;
VCLUnZip1 := TVCLUnZip.Create(nil);
with VCLUnZip1 do
begin
ZipName := FileDir+FileName1;
ReadZip;
Destdir := 解压地址;
RecreateDirs := True;
FilesList.Add('*.*');
DoAll := True;
OverwriteMode := Always;
Password := ''; //加密密码1653
end;
VCLUnZip1.UnZip;
VCLUnZip1.Free;
Result := true;
end;
//=======================压缩文件======================================
if fileexists('D:\compress.zip') then //如果压缩的文件存在则删除
deletefile('D:\compress.zip');
VCLZip1.FilesList.Clear;
VCLZip1.FilesList.Add('D:\compress\RemObjects文档翻译\*.*');//选择要压缩的文件
//VCLZip1.ExcludeList.Add('D:\compress\RemObjects文档翻译\RemObjects文档翻译1_逆水寒提供.doc');//排除不要压缩的文件
VCLZip1.FilesList.Add('D:\compress\SN.TXT');
VCLZip1.FilesList.Add('D:\compress\WINXP服务详解.txt');
VCLZip1.FilesList.Add('D:\compress\新建 文本文档.txt');
VCLZip1.AddDirEntriesOnRecurse := true;
//VCLZip1.Recurse:=true;//压缩子目录
VCLZip1.RelativePaths := true;//压缩相对路径信息
VCLZip1.ZipName := 'D:\compress.zip';//压缩的文件名
//VCLZip1.RootDir:='D:\';
//VCLZip1.StorePaths:=true;//在压缩的文件里面存储路径信息
VCLZip1.MultiZipInfo.WriteDiskLabels := true;
VCLZip1.MultiZipInfo.FirstBlockSize := 200000;
//VCLZip1.DestDir:='D:\test';
VCLZip1.Zip;//开始压缩
//========================解压文件================================
with VCLUnZip1 do
begin
if not busy then
begin
ZipName := 'D:\compress.zip';//解压文件的名字
//VCLUnZip1.RootDir:='D:\test\';
DestDir := 'D:\test\';//解压后文件存放的路径
DoAll := false;//是否解压全部的文件
readzip;//读取压缩文件的信息例如压缩的文件数目
RecreateDirs := true;//是否重建目录
RetainAttributes := True;
for i := 0 to count - 1 do//选择要解压的文件
begin
showmessage(inttostr(i) + '=' + fileName[i]);
if not (i in [0..1]) then
begin
Selected[i] := true;
end;
end;
UnZipSelected;//解压选择的文件
//Unzip;//解压文件
end;