这是个简版的,可以拿来做下网页gzip的解压缩,整好我的webserver还不支持这个,有时间了就加上。
模块zlib.bas的代码如下:
'code by lichmam from cnblogs.com
'whatfor: could be used for http-gziped compress&uncompress
'API declares from zlib.dll
Private Declare Function compress2 Lib "zlib.dll" (dest As Any, _
destLen As Any, _
src As Any, _
ByVal srcLen As Long, _
ByVal level As Long) As Long
Private Declare Function uncompress Lib "zlib.dll" (dest As Any, _
destLen As Any, _
src As Any, _
ByVal srcLen As Long) As Long Public Function Compress(ByRef bytCompressed() As Byte, _
ByRef bytUnCompressed() As Byte, _
Optional CompressionLevel = &) As Long
'0<=CompressionLevel<=9, and default value is 6.
'with the number of CompressionLevel increased,
' the quality, speed of compression would be better and slower.
'however, i'd suggest that JUST TAKE THE DEFAULT VALUE OF COMPRESSION_LEVEL.
Dim srcLen As Long
Dim destLen As Long srcLen = UBound(bytUnCompressed) +
destLen = srcLen * ( + 0.01) +
ReDim bytCompressed(destLen) As Byte
Call compress2(bytCompressed(), destLen, bytUnCompressed(), srcLen, CompressionLevel)
Compress = destLen
End Function Public Function DeCompress(ByRef bytUnCompressed() As Byte, _
ByRef bytCompressed() As Byte) As Long Dim srcLen As Long
Dim destLen As Long srcLen = UBound(bytCompressed) +
destLen = srcLen
ReDim bytUnCompressed(destLen) As Byte
Call uncompress(bytUnCompressed(), destLen, bytCompressed(), srcLen)
DeCompress = destLen
End Function