vb *** 作zlib需要stdcall 的dll,所以dll不对就会出错。
简单版本
Option ExplicitPublic Const Z_OK = 0' Compression levelsPublic Const Z_NO_COMPRESSION As Long = 0Public Const Z_BEST_SPEED As Long = 1Public Const Z_BEST_COMPRESSION As Long = 9Public Const Z_DEFAulT_COMPRESSION As Long = (-1)Public Declare Function compress lib "zlib.dll" (ByVal dest As Long,ByRef destLen As Long,ByVal Source As Long,ByVal sourceLen As Long) As LongPublic Declare Function compress2 lib "zlib.dll" (ByVal dest As Long,ByVal sourceLen As Long,ByVal level As Long) As LongPublic Declare Function compressBound lib "zlib.dll" (ByVal sourceLen As Long) As LongPublic Declare Function uncompress lib "zlib.dll" (ByVal dest As Long,ByVal sourceLen As Long) As Long'ZEXTERN int ZEXPORT compress OF((Bytef *dest,ulongf *destLen,' const Bytef *source,ulong sourceLen));'压缩Public Function ZliB_Compress(bIn() As Byte,bOut() As Byte) As Long' On Error Resume Next Dim bSize As Long Dim lngInSize As Long Dim lngOutSize As Long Dim ret As Long lngInSize = UBound(bIn) + 1' MsgBox compressBound(lngInSize) lngOutSize = (lngInSize * 1.01) + 12'MsgBox lngOutSize ReDim bOut(lngOutSize - 1) As Byte ret = compress(VarPtr(bOut(0)),VarPtr(lngOutSize),VarPtr(bIn(0)),lngInSize)' DeBUG.Print ret ReDim Preserve bOut(lngOutSize - 1) ZliB_Compress = lngOutSizeEnd Function'解压缩数组Public Function ZliB_UnCompress(bIn() As Byte,bOut() As Byte) As Long' On Error Resume Next Dim bSize As Long Dim lngInSize As Long Dim lngOutSize As Long Dim ret As Long lngInSize = UBound(bIn) + 1 lngOutSize = (lngInSize * 15.01) + 12 ReDim bOut(lngOutSize - 1) As Byte' ret = uncompress(0&,VarPtr(bIn(0)),lngInSize)' DeBUG.Print ret ret = uncompress(VarPtr(bOut(0)),lngOutSize,lngInSize) DeBUG.Print ret If ret = 0 Then ReDim Preserve bOut(lngOutSize - 1) ZliB_UnCompress = lngOutSize Else ReDim Preserve bOut(0) End IfEnd Function总结
以上是内存溢出为你收集整理的zlib vb *** 作类1全部内容,希望文章能够帮你解决zlib vb *** 作类1所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)