VBA及VB三種不同壓縮解壓組件/控件的性能對(duì)比報(bào)告(zlib.dll,info-zip,xceed zip)
- 2017-09-08 22:38:00
- 百度知道 轉(zhuǎn)貼
- 4790
VBA及VB三種不同壓縮解壓組件/控件的性能對(duì)比報(bào)告
VB Access Excel本身沒有自己的壓縮和解壓縮函數(shù)和組件,必須依賴于第三方的控件或動(dòng)態(tài)鏈接庫,以下是三種不同壓縮組件的性能對(duì)比詳細(xì)報(bào)告
VB中使用三種不同組件進(jìn)行內(nèi)存解壓的結(jié)果分析比較
本文采用三種不同軟件公司的動(dòng)態(tài)鏈接庫組件,分別進(jìn)行內(nèi)存解壓縮實(shí)驗(yàn),這三種組件分別是:
1、 使用zlib 軟件公司的zlib.dll動(dòng)態(tài)鏈接庫組件進(jìn)行內(nèi)存解壓
2、 使用info-zip軟件公司的vbuzip10.dll(也就是unzip32.dll)動(dòng)態(tài)鏈接庫組件進(jìn)行內(nèi)存解壓
3、 使用xceed軟件公司的xceed zip compression library V5.0版本的xceedzip.dll動(dòng)態(tài)鏈接庫組件進(jìn)行內(nèi)存解壓
利用上述三種不同軟件公司的動(dòng)態(tài)鏈接庫組件,對(duì)解壓前大小為229046805字節(jié)的壓縮文件進(jìn)行解壓實(shí)驗(yàn),實(shí)驗(yàn)結(jié)果如下:
1、采用三種不同軟件公司的動(dòng)態(tài)鏈接庫組件分別進(jìn)行內(nèi)存解壓,三次內(nèi)存解壓所用時(shí)間(毫秒)如下:
軟件名稱 第一次 第二次 第三次 平均時(shí)間
vbuzip10.dll: 1734 1703 1672 1703
xceedzip.dll: 9562 4313 4453 6109.3
zlib.dll: 2594 2563 2562 2573
從上面數(shù)據(jù)可以看出,使用info-zip軟件公司的vbuzip10.dll組件進(jìn)行內(nèi)存解壓,所用時(shí)間最少,即采用vbuzip10.dll組件進(jìn)行內(nèi)存解壓的速度最快,其次是zlib.dll,速度最慢的是xceedzip.dll。
2、使用info-zip軟件公司的vbuzip10.dll組件進(jìn)行內(nèi)存解壓,對(duì)于被解壓的壓縮文件,如果文件較?。ń鈮呵白止?jié)大小少于1016字節(jié)的壓縮文件),解壓后可以得到所有的文件內(nèi)容;但如果文件較大(解壓前字節(jié)大小大于2807字節(jié)的壓縮文件),解壓后最多只能得到2807字節(jié)的文件內(nèi)容。其它內(nèi)容雖然也在內(nèi)存中,但無法讀取。同時(shí),當(dāng)文件較大(解壓前字節(jié)大小大于1016字節(jié)的壓縮文件),解壓時(shí)甚至?xí)霈F(xiàn)程序運(yùn)行崩潰的情況,因此,使用info-zip軟件公司的vbuzip10.dll組件進(jìn)行內(nèi)存解壓,很不可靠。
3、使用info-zip軟件公司的vbuzip10.dll組件進(jìn)行內(nèi)存解壓,得到的解壓后的內(nèi)容,直接就可以得到字符串,不用再進(jìn)行字節(jié)到字符串的轉(zhuǎn)換;而用xceedzip.dll和zlib.dll組件進(jìn)行內(nèi)存解壓,得到的解壓后的內(nèi)容是字節(jié)數(shù)組,不是字符串,需要通過字節(jié)數(shù)組到字符串的轉(zhuǎn)換,才能得到真正的字符串,如果不進(jìn)行字節(jié)數(shù)組到字符串的轉(zhuǎn)換,則得到的字符串是一串亂碼。
4、使用zlib.dll組件進(jìn)行內(nèi)存解壓,只需要在VB的申明部分用下列語句進(jìn)行申明:
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
然后在程序中加入下列語句,即可在程序中調(diào)用他們的函數(shù)進(jìn)行內(nèi)存解壓縮:
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)
解壓后得到的內(nèi)容在str_tmp字符串變量中:
5、使用vbuzip10.dll組件進(jìn)行內(nèi)存解壓,只需要在VB的申明部分用下列語句進(jìn)行申明,
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
然后在程序中加入下列語句,即可在程序中調(diào)用他們的函數(shù)進(jìn)行內(nèi)存解壓縮:
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)
解壓后得到的內(nèi)容在retstr.buffer字符串變量中:
6、使用xceedzip.dll組件進(jìn)行內(nèi)存解壓,比較麻煩,需要先在計(jì)算機(jī)上運(yùn)行XceedComponents.exe程序,安裝xceed zip compression library V5.0和其它組件,然后在VB設(shè)計(jì)環(huán)境下,在“工程”---“引用”中,引用“xceed zip compression Library V5.0”,在“工程”---“部件”中,將“xceed zip compression Library V5.0”前的復(fù)選框選中,這樣在VB設(shè)計(jì)環(huán)境下,在工具箱中,就可以看到一個(gè)xceedzip工具圖標(biāo),將該圖標(biāo)加到窗體中,在程序中加入下列語句:
Dim zipfilename As String, filenameinzip As String, REsult_Code1 As xcdError
XceedZip1.zipfilename = zipfilename
XceedZip1.FilesToProcess = filenameinzip
REsult_Code1 = XceedZip1.Unzip
即可在程序中調(diào)用他們的函數(shù)進(jìn)行內(nèi)存解壓縮,解壓后得到的內(nèi)容在filetext字符串變量中:
Private Sub XceedZip1_UnzippingMemoryFile(ByVal sFilename As String, vaUncompressedData As Variant, ByVal bEndOfData As Boolean)
filetext = StrConv(vaUncompressedData, vbUnicode)
End Sub
- office課程播放地址及課程明細(xì)
- Excel Word PPT Access VBA等Office技巧學(xué)習(xí)平臺(tái)
- 將( .accdb) 文件格式數(shù)據(jù)庫轉(zhuǎn)換為早期版本(.mdb)的文件格式
- 將早期的數(shù)據(jù)庫文件格式(.mdb)轉(zhuǎn)換為 (.accdb) 文件格式
- KB5002984:配置 Jet Red Database Engine 數(shù)據(jù)庫引擎和訪問連接引擎以阻止對(duì)遠(yuǎn)程數(shù)據(jù)庫的訪問(remote table)
- Access 365 /Access 2019 數(shù)據(jù)庫中哪些函數(shù)功能和屬性被沙箱模式阻止(如未啟動(dòng)宏時(shí))
- Access Runtime(運(yùn)行時(shí))最全的下載(2007 2010 2013 2016 2019 Access 365)
- access vba代碼太長(zhǎng),換行,分行的寫法
- VB6 VBA Access真正可用并且完美支持中英文的 URLEncode 與 URLDecode 函數(shù)源碼
- 自定義VB中的urlencode函數(shù),將URL中特殊部分進(jìn)行編碼
- Access 函數(shù)簡(jiǎn)化串接sql字符串,減少符號(hào)導(dǎo)致的書寫錯(cuò)誤
- vba完全關(guān)閉IE瀏覽器及調(diào)用IE瀏覽器的簡(jiǎn)單應(yīng)用
- 利用FollowHyperlink方法打開超鏈接提示“無法下載您要求的信息”的解決方案
- 在access中用代碼打開文本框中超鏈接地址
- Activex控件或Dll 在某些電腦無法正常注冊(cè)的解決辦法(regsvr32注冊(cè)時(shí)卡?。?/a>
- office使用部分控件時(shí)提示“您沒有使用該ActiveX控件許可的問題”的解決方法
- RTF文件(富文本格式)的一些解析
- Access樹控件(treeview) 64位Office下出現(xiàn)橫向滾動(dòng)條不會(huì)自動(dòng)定位的解決辦法
- Access中國樹控件 在win10電腦 節(jié)點(diǎn)行間距太小的解決辦法
- EXCEL 2019 64位版(Office 2019 64位)早就支持64位Treeview 樹控件 ListView列表等64位MSCOMMCTL.OCX控件下載
- VBA或VB6調(diào)用WebService(直接Post方式)并解析返回的XML
- 早期PB程序連接Sqlserver出現(xiàn)錯(cuò)誤
- MMC 不能打開文件C:/Program Files/Microsoft SQL Server/80/Tools/Binn/SQL Server Enterprise Manager.MSC 可能是由于文件不存在,不是一個(gè)MMC控制臺(tái),或者用后來的MMC版
- sql server連接不了的解決辦法
- localhost與127.0.0.1區(qū)別
- Roych的淺談數(shù)據(jù)庫開發(fā)系列(Sql Server)
- sqlserver 自動(dòng)備份對(duì)備份目錄沒有存取權(quán)限的解決辦法
- 安裝Sql server 2005 express 和SQLServer2005 Express版企業(yè)管理器 SQLServer2005_SSMSEE
聯(lián)系人: | 王先生 |
---|---|
Email: | 18449932@qq.com |
QQ: | 18449932 |
微博: | officecn01 |