最近写一个程序,用到很多小文件,这些小文件不能合并,但是要在程序中调用,于是想把这些小文件放在压缩包内,需要的时候在从里面取,程序中产生的文件可以往压缩包内放。请问实现这些功能的方法?实现该功能过程中不要产生临时文件最好。
经过一番搜索发现了zlib和infozip,但是我不太懂C,其实也就是能看懂简单的C程序,找了一些别人编译的dll,其中一个是LiteZip/LiteUnzip(http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=33fa67ff-a665-455a-8789-c5b59c9d8d5a),用法比较简单,但是我测试时发现可以按照说明创建空压缩文件,但往里面添加文件时,VB6就出现了错误,直接退出了,请大家看看是怎么回事?另外还有没有其它方法实现这个功能,最好是基于zlib和infozip,如能像LiteZip/LiteUnzip提供dll或控件非常感谢。不知道有没有用VB实现压缩和解压的代码如果觉得分数不够,我可以再加。
经过一番搜索发现了zlib和infozip,但是我不太懂C,其实也就是能看懂简单的C程序,找了一些别人编译的dll,其中一个是LiteZip/LiteUnzip(http://forum.csdn.net/PointForum/Forum/PostTopic.aspx?forumID=33fa67ff-a665-455a-8789-c5b59c9d8d5a),用法比较简单,但是我测试时发现可以按照说明创建空压缩文件,但往里面添加文件时,VB6就出现了错误,直接退出了,请大家看看是怎么回事?另外还有没有其它方法实现这个功能,最好是基于zlib和infozip,如能像LiteZip/LiteUnzip提供dll或控件非常感谢。不知道有没有用VB实现压缩和解压的代码如果觉得分数不够,我可以再加。
解决方案 »
- SQL数据库查询问题
- 如何在VB下用SendInput这个API?
- 編譯後的exe應用程序越來越大,各位有什麼辦法變小啊
- 请问如何改变datagrid控件中的表中字段名称?
- 奇怪的问题
- 不好意思再次麻烦大家~我的上一个问题还没有解决(怎么给热心人分那,我好象给过了但是有看不到)
- vb 6.0 关于INI文件的一个问题
- 在vb中如何在一个窗体中调用另个一个窗体,且把该窗体放在一个容器控件(如frame)中,
- Microsoft Transaction Server Type Library ?
- 如何用VB编程来实现用数据相机或摄像机在电脑上同步显示图像?
- Form 加载为新开,而不是覆盖
- 好长时间了。。。终于注册成功了一个马甲。。。。我保证不会倒分,哈哈~~~~所以来散出50%分~~~~
Option Explicit
Private Declare Function ZipCreateFile Lib "litezip" Alias "ZipCreateFileA" (ByRef hZip As Long, ByVal filename As String, ByVal password As String) As Long
Private Declare Function ZipAddFile Lib "litezip" Alias "ZipAddFileA" (ByVal hZip As Long, ByVal filename As String) As Long
Private Declare Function ZipClose Lib "litezip" (ByVal hZip As Long) As Long
Private Declare Function ZipCreateBuffer Lib "litezip" (hZip As Long, ByVal lpBuffer As Long, ByVal size As Long, password As String) As Long
Private Declare Function ZipCreateHandle Lib "litezip" (hZip As Long, ByVal fileHandle As Long, password As String) As Long
Private Declare Function ZipAddHandle Lib "litezip" Alias "ZipAddHandleA" (ByVal hZip As Long, zipname As String, ByVal fileHandle As Long) As Long
Private Declare Function ZipAddBuffer Lib "litezip" Alias "ZipAddBufferA" (ByVal hZip As Long, zipname As String, ByVal lpBuffer As Long, ByVal size As Long) As Long
Private Declare Function ZipAddPipe Lib "litezip" Alias "ZipAddPipeA" (ByVal hZip As Long, zipname As String, ByVal fileHandle As Long, ByVal size As Long) As Long
Private Declare Function ZipAddFolder Lib "litezip" Alias "ZipAddFolderA" (ByVal hZip As Long, zipname As String) As Long
Private Declare Function ZipGetMemory Lib "litezip" (ByVal hZip As Long, bufferPtr As Long, size As Long, freeHandle As Long) As Long
Private Declare Function ZipResetMemory Lib "litezip" (ByVal hZip As Long) As Long
Private Declare Function ZipOptions Lib "litezip" (ByVal hZip As Long, ByVal flags As Long) As Long
Private Declare Function ZipFormatMessage Lib "litezip" Alias "ZipFormatMessageA" (ByVal errornumber As Long, lpBuffer As String, ByVal buffersize As Long) As Long
Private Declare Function ZipAddDir Lib "litezip" Alias "ZipAddDirA" (ByVal hZip As Long, dirname As String, ByVal offset As Long) As Long
Private Sub Form_Click()
Dim iii As Long, hhzip As Long, jjj As Long
iii = ZipCreateFile(hhzip, "E:\Work-Temp\VB小程序\ZlibTool1\tttt.zip", 0)
jjj = ZipAddFile(hhzip, "E:\Work-Temp\VB小程序\ZlibTool1\test.jpg")
End Sub
这个Dll在VB2005中没有任何问题,可以实现,但是我对2005现在还不熟悉,因此这个程序比较急,等熟悉了VB2005,用6都做出来,唉