VBA及VB三種不衕壓縮解壓組件/控件的性能對比報告(zlib.dll,info-zip,xceed zip)
- 2017-09-08 22:38:00
- 百度知道 轉貼
- 4592
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 |