zoukankan      html  css  js  c++  java
  • VB6之借助zlib实现gzip解压缩

    这是个简版的,可以拿来做下网页gzip的解压缩,整好我的webserver还不支持这个,有时间了就加上。

    zlib.dll下载请点击我!

    模块zlib.bas的代码如下:

     1 'code by lichmam from cnblogs.com
     2 'whatfor: could be used for http-gziped compress&uncompress
     3 'API declares from zlib.dll
     4 Private Declare Function compress2 Lib "zlib.dll" (dest As Any, _
     5     destLen As Any, _
     6     src As Any, _
     7     ByVal srcLen As Long, _
     8     ByVal level As Long) As Long
     9 Private Declare Function uncompress Lib "zlib.dll" (dest As Any, _
    10     destLen As Any, _
    11     src As Any, _
    12     ByVal srcLen As Long) As Long
    13     
    14 Public Function Compress(ByRef bytCompressed() As Byte, _
    15     ByRef bytUnCompressed() As Byte, _
    16     Optional CompressionLevel = 6&) As Long
    17     '0<=CompressionLevel<=9, and default value is 6.
    18     'with the number of CompressionLevel increased,
    19     '   the quality, speed of compression would be better and slower.
    20     'however, i'd suggest that JUST TAKE THE DEFAULT VALUE OF COMPRESSION_LEVEL.
    21     Dim srcLen As Long
    22     Dim destLen As Long
    23     
    24     srcLen = UBound(bytUnCompressed) + 1
    25     destLen = srcLen * (1 + 0.01) + 12
    26     ReDim bytCompressed(destLen) As Byte
    27     Call compress2(bytCompressed(0), destLen, bytUnCompressed(0), srcLen, CompressionLevel)
    28     Compress = destLen
    29 End Function
    30 
    31 Public Function DeCompress(ByRef bytUnCompressed() As Byte, _
    32     ByRef bytCompressed() As Byte) As Long
    33 
    34     Dim srcLen As Long
    35     Dim destLen As Long
    36     
    37     srcLen = UBound(bytCompressed) + 1
    38     destLen = srcLen
    39     ReDim bytUnCompressed(destLen) As Byte
    40     Call uncompress(bytUnCompressed(0), destLen, bytCompressed(0), srcLen)
    41     DeCompress = destLen
    42 End Function
  • 相关阅读:
    JAVA中添加jar包
    shell 脚本读取数据库示例
    Div 布局之 DIV垂直居中显示
    awk 学习笔记
    提示ufmyhr日志已满,无法继续操作软件,如何解决
    12种貌似卫生的不卫生习惯
    远程通客户端反复提示要下载客户端软件
    固定资产反启用后再启用报00:00:00错误
    2008年5月14日
    睡前六个必要动作,一觉睡到大天亮
  • 原文地址:https://www.cnblogs.com/lichmama/p/3838067.html
Copyright © 2011-2022 走看看