VBA及VB三种不同压缩解压组件/控件的性能对比报告(zlib.dll,info-zip,xceed zip)
- 2017-09-08 22:38:00
- 百度知道 转贴
- 4619
VBA及VB三种不同压缩解压组件/控件的性能对比报告
VB Access Excel本身没有自己的压缩和解压缩函数和组件,必须依赖于第三方的控件或动态链接库,以下是三种不同压缩组件的性能对比详细报告
VB中使用三种不同组件进行内存解压的结果分析比较
本文采用三种不同软件公司的动态链接库组件,分别进行内存解压缩实验,这三种组件分别是:
1、 使用zlib 软件公司的zlib.dll动态链接库组件进行内存解压
2、 使用info-zip软件公司的vbuzip10.dll(也就是unzip32.dll)动态链接库组件进行内存解压
3、 使用xceed软件公司的xceed zip compression library V5.0版本的xceedzip.dll动态链接库组件进行内存解压
利用上述三种不同软件公司的动态链接库组件,对解压前大小为229046805字节的压缩文件进行解压实验,实验结果如下:
1、采用三种不同软件公司的动态链接库组件分别进行内存解压,三次内存解压所用时间(毫秒)如下:
软件名称 第一次 第二次 第三次 平均时间
vbuzip10.dll: 1734 1703 1672 1703
xceedzip.dll: 9562 4313 4453 6109.3
zlib.dll: 2594 2563 2562 2573
从上面数据可以看出,使用info-zip软件公司的vbuzip10.dll组件进行内存解压,所用时间最少,即采用vbuzip10.dll组件进行内存解压的速度最快,其次是zlib.dll,速度最慢的是xceedzip.dll。
2、使用info-zip软件公司的vbuzip10.dll组件进行内存解压,对于被解压的压缩文件,如果文件较小(解压前字节大小少于1016字节的压缩文件),解压后可以得到所有的文件内容;但如果文件较大(解压前字节大小大于2807字节的压缩文件),解压后最多只能得到2807字节的文件内容。其它内容虽然也在内存中,但无法读取。同时,当文件较大(解压前字节大小大于1016字节的压缩文件),解压时甚至会出现程序运行崩溃的情况,因此,使用info-zip软件公司的vbuzip10.dll组件进行内存解压,很不可靠。
3、使用info-zip软件公司的vbuzip10.dll组件进行内存解压,得到的解压后的内容,直接就可以得到字符串,不用再进行字节到字符串的转换;而用xceedzip.dll和zlib.dll组件进行内存解压,得到的解压后的内容是字节数组,不是字符串,需要通过字节数组到字符串的转换,才能得到真正的字符串,如果不进行字节数组到字符串的转换,则得到的字符串是一串乱码。
4、使用zlib.dll组件进行内存解压,只需要在VB的申明部分用下列语句进行申明:
Private Declare Function unzOpen Lib "ZLIB.DLL" (ByVal FilePath As String) As Long
Private Declare Function unzClose Lib "ZLIB.DLL" (ByVal hFile As Long) As Long
Private Declare Function unzGetGlobalInfo Lib "ZLIB.DLL" (ByVal hFile As Long, ByRef pglobal_info As unz_global_info) As Long
Private Declare Function unzGetCurrentFileInfo Lib "ZLIB.DLL" (ByVal hFile As Long, ByRef pfile_info As unz_file_info, ByVal szFileName As String, ByVal fileNameBufferSize As Long, ByRef extraField As Long, ByVal extraFieldBufferSize As Long, ByVal szComment As String, ByVal commentBufferSize As String) As Long
Private Declare Function unzOpenCurrentFile Lib "ZLIB.DLL" (ByVal hFile As Long) As Long
Private Declare Function unzCloseCurrentFile Lib "ZLIB.DLL" (ByVal hFile As Long) As Long
Private Declare Function unzReadCurrentFile Lib "ZLIB.DLL" (ByVal hFile As Long, ByRef Buffer As Byte, ByVal BuffLen As Long) As Long
Private Declare Function unzGoToNextFile Lib "ZLIB.DLL" (ByVal hFile As Long) As Long
然后在程序中加入下列语句,即可在程序中调用他们的函数进行内存解压缩:
Dim zipfilename As String, str_tmp As String, filenameinzip As String
zipfilename = "q-20151010-1406-0000-4.zip"
filenameinzip = "q-20151010-pfsjnl.bin"
str_tmp = UnZipToMemory(zipfilename, filenameinzip)
解压后得到的内容在str_tmp字符串变量中:
5、使用vbuzip10.dll组件进行内存解压,只需要在VB的申明部分用下列语句进行申明,
Public Declare Function Wiz_UnzipToMemory Lib "vbuzip10.dll" (ByVal zip As String, ByVal file As String, ByRef lpUserFunc As LPUSERFUNCTIONS, ByRef retstr As UzpBuffer) As Long
Public Declare Sub UzpFreeMemBuffer Lib "vbuzip10.dll" (ByRef retstr As UzpBuffer)
Public Type UzpBuffer
strlength As Long
Buffer As String
End Type
Private Type UNZIPCBChar
ch(32800) As Byte
End Type
Private Type UNZIPCBCh
ch(256) As Byte
End Type
Public Type LPUSERFUNCTIONS
printwq As Long 'DLLPRNT * = a pointer to the application's print routine.
sound As Long 'DLLSND * = a pointer to the application's sound routine. This
' can be NULL if your application doesn't use sound.
replace As Long 'DLLREPLACE * = a pointer to the application's replace routine.
password As Long 'DLLPASSWORD * = a pointer to the application's password routine.
SendApplicationMessage As Long 'DLLMESSAGE * = a pointer to the application's routine
'for displaying information about specific files
'in the archive. Used for listing the contents of an archive.
ServCallBk As Long 'DLLSERVICE * = Callback function designed to be used for
' allowing the application to process Windows messages,
' or canceling the operation, as well as giving the
' option of a progress indicator. If this function
' returns a non-zero value, then it will terminate
' what it is doing. It provides the application with
' the name of the name of the archive member it has
' just processed, as well as it's original size.
'NOTE: The values below are filled in only when listing the contents of an archive.
TotalSizeComp As Long '= value to be filled in by the dll for the
'compressed total size of the archive. Note this
'value does not include the size of the archive
'header and central directory list.
TotalSize As Long '= value to be filled in by the dll for the total
' size of all files in the archive.
CompFactor As Long '= value to be filled in by the dll for the overall
' compression factor. This could actually be computed
' from the other values, but it is available.
NumMembers As Long '= total number of files in the archive.
cchComment As Integer 'WORD = flag to be set if archive has a comment
End Type
然后在程序中加入下列语句,即可在程序中调用他们的函数进行内存解压缩:
Dim retstr As UzpBuffer, UZUSER As LPUSERFUNCTIONS, long_result As Long, zipfilename As String, filenameinzip As String
UZUSER.printwq = FnPtr(AddressOf UZDLLPrnt)
UZUSER.sound = 0& '-- Not Supported
UZUSER.replace = FnPtr(AddressOf UZDLLRep)
UZUSER.password = FnPtr(AddressOf UZDLLPass)
UZUSER.SendApplicationMessage = FnPtr(AddressOf UZReceiveDLLMessage)
UZUSER.ServCallBk = FnPtr(AddressOf UZDLLServ)
zipfilename = "q-20151010-1406-0000-4.zip"
filenameinzip = "q-20151010-pfsjnl.bin"
long_result = Wiz_UnzipToMemory(zipfilename, filenameinzip, UZUSER, retstr)
解压后得到的内容在retstr.buffer字符串变量中:
6、使用xceedzip.dll组件进行内存解压,比较麻烦,需要先在计算机上运行XceedComponents.exe程序,安装xceed zip compression library V5.0和其它组件,然后在VB设计环境下,在“工程”---“引用”中,引用“xceed zip compression Library V5.0”,在“工程”---“部件”中,将“xceed zip compression Library V5.0”前的复选框选中,这样在VB设计环境下,在工具箱中,就可以看到一个xceedzip工具图标,将该图标加到窗体中,在程序中加入下列语句:
Dim zipfilename As String, filenameinzip As String, REsult_Code1 As xcdError
XceedZip1.zipfilename = zipfilename
XceedZip1.FilesToProcess = filenameinzip
REsult_Code1 = XceedZip1.Unzip
即可在程序中调用他们的函数进行内存解压缩,解压后得到的内容在filetext字符串变量中:
Private Sub XceedZip1_UnzippingMemoryFile(ByVal sFilename As String, vaUncompressedData As Variant, ByVal bEndOfData As Boolean)
filetext = StrConv(vaUncompressedData, vbUnicode)
End Sub
- office课程播放地址及课程明细
- Excel Word PPT Access VBA等Office技巧学习平台
- 将( .accdb) 文件格式数据库转换为早期版本(.mdb)的文件格式
- 将早期的数据库文件格式(.mdb)转换为 (.accdb) 文件格式
- KB5002984:配置 Jet Red Database Engine 数据库引擎和访问连接引擎以阻止对远程数据库的访问(remote table)
- Access 365 /Access 2019 数据库中哪些函数功能和属性被沙箱模式阻止(如未启动宏时)
- Access Runtime(运行时)最全的下载(2007 2010 2013 2016 2019 Access 365)
- Activex控件或Dll 在某些电脑无法正常注册的解决办法(regsvr32注册时卡住)
- office使用部分控件时提示“您没有使用该ActiveX控件许可的问题”的解决方法
- RTF文件(富文本格式)的一些解析
- Access树控件(treeview) 64位Office下出现横向滚动条不会自动定位的解决办法
- Access中国树控件 在win10电脑 节点行间距太小的解决办法
- EXCEL 2019 64位版(Office 2019 64位)早就支持64位Treeview 树控件 ListView列表等64位MSCOMMCTL.OCX控件下载
- VBA或VB6调用WebService(直接Post方式)并解析返回的XML
- 早期PB程序连接Sqlserver出现错误
- MMC 不能打开文件C:/Program Files/Microsoft SQL Server/80/Tools/Binn/SQL Server Enterprise Manager.MSC 可能是由于文件不存在,不是一个MMC控制台,或者用后来的MMC版
- sql server连接不了的解决办法
- localhost与127.0.0.1区别
- Roych的浅谈数据库开发系列(Sql Server)
- sqlserver 自动备份对备份目录没有存取权限的解决办法
- 安装Sql server 2005 express 和SQLServer2005 Express版企业管理器 SQLServer2005_SSMSEE
联系人: | 王先生 |
---|---|
Email: | 18449932@qq.com |
QQ: | 18449932 |
微博: | officecn01 |