天天看點

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(請注明來意)

繼續閱讀