Delphi中对Gzip解压代码

使用函数前请安装第三方控件ZlibEX控件,本人博客内 有下载资源

procedure DecompressGZip(AInStream, AOutStream: TStream);
var
  pb1, pb2: Byte;
begin
  AInStream.Seek(1, 0);
  AInStream.Read(pb1, 1);
  AInStream.Seek(2, 0);
  AInStream.Read(pb2, 1);
  AInStream.Position := 0;
  AOutStream.Position := 0;
  if (pb1 = $8B) and (pb2 = $8) then
    ZDecompressStream2(AInStream, AOutStream, 47)
  else
    AOutStream.CopyFrom(AInStream, AInStream.Size);
end;

 

如有疑问请欢迎联系沟通,QQ:2609715119(请注明来意)

你可能感兴趣的:(Delphi,计算机技术,Gzip)