用 Zlib 压缩数据, 通过流存储,可以使用下面函数实现解压:

function UnZipStream(Input, Output: TStream; var Buf: PByte): Boolean;
var
DS: TDecompressionStream;
nBufSize: Integer;
begin
Result := False;
if Assigned(Input) and Assigned(Output) then
begin
Input.Position := 0;
Output.Position := 0;
DS := TDecompressionStream.Create(Input);
try
nBufSize := DS.Read(Buf^, ZIP_MAX_BUF_SIZE);
while nBufSize > 0 do
begin
Output.Write(Buf^, nBufSize);
nBufSize := DS.Read(Buf^, ZIP_MAX_BUF_SIZE);
end;
if Output.Position > 0 then
begin
Result := true;
Exit;
end;
finally
DS.Free;
end;
end;
end;