狠k了一下zlib的sample,终于解决问题了<br>用到inflate函数, 最小只解压64字节都可以啊<br>20m的文件读取文件头不要1秒 ;-)<br>function Inf(var input: PChar; var output: PChar): integer;<br><br> function InflateInit(var stream: z_stream): Integer;<br> begin<br> result := InflateInit_(stream, zlibVersion, SizeOf(z_stream));<br> end;<br><br>var<br> ret: integer;<br> have: WORD;<br> strm: z_stream;<br>begin<br> strm.zalloc := Z_NULL;<br> strm.zfree := Z_NULL;<br> strm.opaque := Z_NULL;<br> strm.avail_in := 0;<br> strm.next_in := Z_NULL;<br> ret:= inflateInit(strm);<br><br> if ret<>Z_OK then<br> begin<br> result:=ret;<br> exit;<br> end;<br><br> repeat<br> strm.avail_in := CHUNK;<br> strm.next_in := input;<br><br> repeat<br> strm.avail_out := CHUNK;<br> strm.next_out := output;<br> ret := inflate(@strm, Z_NO_FLUSH);<br> have := CHUNK - strm.avail_out;<br><br> until strm.avail_out <> 0;<br><br> ret:= Z_STREAM_END;<br> until ret = Z_STREAM_END;<br><br> inflateEnd(@strm);<br><br> result:= Z_STREAM_END<br>end;