用Zlib吧,Delphi自带。也可以去官网下载C的,开源,Delphi下提供一个PAS文件调用 uses ...,Zlib; function zipStr2Str(Str: string): string; var instream: Tmemorystream; zstream: Tcompressionstream; outstream: Tmemorystream; size: integer; begin instream := Tmemorystream.Create; try instream.Write(Str[1], Length(Str)); if instream.Size = 0 then exit; size := instream.size; outstream := Tmemorystream.create; zstream := Tcompressionstream.Create(clmax, outstream); try instream.SaveToStream(zstream); zstream.free; outstream.Position := 0; instream.clear; instream.WriteBuffer(size, sizeof(size)); instream.CopyFrom(outstream, 0); instream.Position := 0; SetLength(Result, instream.Size); instream.ReadBuffer(Result[1], instream.Size); finally outstream.free; end; finally instream.Free; end; end; function UnzipStr2Str(Str: string): string; var instream: Tmemorystream; zstream: Tdecompressionstream; outstream: Tmemorystream; size: integer; buffer: pchar; begin instream := Tmemorystream.Create; try instream.Write(Str[1], Length(Str)); if instream.Size = 0 then exit; instream.Position := 0; instream.ReadBuffer(size, sizeof(size)); getmem(buffer, size); outstream := Tmemorystream.create; zstream := Tdecompressionstream.Create(instream); try zstream.Readbuffer(buffer^, size); outstream.WriteBuffer(buffer^, size); outstream.Position := 0; instream.clear; instream.CopyFrom(outstream, 0); instream.Position := 0; SetLength(Result, instream.Size); instream.ReadBuffer(Result[1], instream.Size); finally zstream.free; outstream.Free; freemem(buffer); end; finally instream.Free; end; end;