uses zlib;Procedure ZipFile(Source, OutFileName:String);//文件压缩var F:TCompressionStream; FSource,Fzip:TFileStream; i:integer;begin FSource:=TFileStream.Create(Source,fmOpenRead); i:= FSource.Size; FZip:=TFileStream.Create(OutFileName,fmCreate); F:=TCompressionStream.Create(clDefault,Fzip); Try F.CopyFrom(FSource,0); Finally F.Free; FSource.Free; End; Fzip.Write(i,sizeof(i)); Fzip.Free;end;procedure UnZipFIle(Source,OutFileName:String); //文件解压var F:TDecompressionStream; FSource,FUnzip:TFileStream; Buffer: PChar; i:integer;begin if not FileExists(Source) Then Exit; DeleteTmpFile; FSource:=TFileStream.Create(Source,fmOpenRead); FUnzip:=TFileStream.Create(OutFileName,fmCreate); FSource.Position:=FSource.Size-Sizeof(integer); FSource.Read(i,sizeof(i)); FSource.Position:=0; Try F:=TDecompressionStream.Create(FSource); Finally End; GetMem(Buffer,i); F.Read(Buffer^,i); FUnzip.WriteBuffer(Buffer^,i); FreeMem(Buffer); F.Free; FSource.Free; FUnZip.Free;end;不过压缩后的文件,好像不能通过winrar解压,只能使用上面的函数解压。