-
Jul 8th, 2012, 06:37 AM
#1
[VB6] 7-zip support
Here is an open source project that provides support for 7-zip in your VB6 projects.
https://github.com/wqweto/VszLib
Using VszLib.dll + 7z.dll your applications can create and extract 7z, zip, tar.gz, tar.bz2 and many more compression formats. Latest versions of 7z format include LZMA2 method for faster multi-core compression.
Post your comments and questions here.
cheers,
</wqw>
Last edited by wqweto; Mar 30th, 2020 at 02:57 AM.
-
Jul 8th, 2012, 10:08 AM
#2
Re: [VB6] 7-zip support
Excellent code! Thanks for making it Open-Source!
BTW, are there plans to support Unicode?
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jul 9th, 2012, 06:50 AM
#3
Re: [VB6] 7-zip support
@Bonnie West: You mean unicode API for file handling and for creating long path+filenames?
Unicode support depends on archive entries handling by archive format. For instance original ZIP format does not support unicode file names.
I'll think about it, probably will have to use conditional compilation to support non-unicode filenames on 9x OSes.
cheers,
</wqw>
-
Jul 10th, 2012, 03:09 AM
#4
Re: [VB6] 7-zip support
@ wqweto
Yes. Since your project deals primarily with adding support for the 7-Zip format for VB6, I thought, why not include Unicode-aware file handling as well? I've just tested the 7-Zip File Manager and it can deal with Unicode filenames pretty well. But of course, it's up to you if you want to implement it or not. Consider my 'request' as a suggestion only.
Last edited by Bonnie West; Jul 10th, 2012 at 03:28 AM.
On Local Error Resume Next: If Not Empty Is Nothing Then Do While Null: ReDim i(True To False) As Currency: Loop: Else Debug.Assert CCur(CLng(CInt(CBool(False Imp True Xor False Eqv True)))): Stop: On Local Error GoTo 0
Declare Sub CrashVB Lib "msvbvm60" (Optional DontPassMe As Any)
-
Jul 17th, 2012, 06:52 AM
#5
Lively Member
Re: [VB6] 7-zip support
Hello, thanks for your effort, I have searched for many months something like this.
I have few questions:
1. Does it work with zip\rar?
2. How can you check, after extract proccess, if all files were extracted successfuly?
Thanks again! and good job!
-
Jul 18th, 2012, 10:30 AM
#6
Re: [VB6] 7-zip support
Hi,
1. 7z.dll can compress/decompress zip files and only decompress rar files. There is a smaller version (7za.dll) of the 7-zip library that handles only 7z format.
2. Usually `Extract` method will return False. You can sink `Error` event too.
cheers,
</wqw>
-
Dec 12th, 2012, 10:09 AM
#7
Junior Member
Re: [VB6] 7-zip support
VszLib do not work when i compile the classes inside a normal EXE, the .7z file is smaller and corrupt
but it works when inside the IDE or when compiled inside a DLL, strange
Last edited by sergelac; Dec 12th, 2012 at 10:56 AM.
-
Jan 5th, 2013, 01:12 PM
#8
Re: [VB6] 7-zip support
@sergelac: Probably threading issues. 7-zip spawns threads and does not care to initialize COM on these but insists on doing I/O on the supplied callback interfaces.
Never managed to make it stable in Standard Exe, so I'm using it as an ActiveX Dll in my apps. P-code compilation (always used in IDE) alleviates problems somehow but still is not production stable.
cheers,
</wqw>
-
Jul 6th, 2013, 02:01 PM
#9
Junior Member
Re: [VB6] 7-zip support
Very Very good work!
I need 7z support for vb6 and find vszlib.
I only need single thread to extract .7z file
So I only need use m_oInArchive.Extract, I needn't use pvWaitThread for mult threads.
So I think i can use it in Standard exe.
Thanks wqweto.
Last edited by mjohnlq; Jul 6th, 2013 at 02:20 PM.
-
Jul 6th, 2013, 03:08 PM
#10
Junior Member
Re: [VB6] 7-zip support
After I tried, I found vszlib can't extract exe file in 7z file.
-
Jul 27th, 2013, 05:21 PM
#11
Re: [VB6] 7-zip support
Originally Posted by mjohnlq
After I tried, I found vszlib can't extract exe file in 7z file.
Did you try referencing the VszLib.dll (not using the sources)? What king of archive are you trying to extract from -- 7z, zip, rar?
cheers,
</wqw>
-
Sep 4th, 2013, 04:38 AM
#12
Re: [VB6] 7-zip support
Originally Posted by Bonnie West
@ wqweto
Yes. Since your project deals primarily with adding support for the 7-Zip format for VB6, I thought, why not include Unicode-aware file handling as well? I've just tested the 7-Zip File Manager and it can deal with Unicode filenames pretty well. But of course, it's up to you if you want to implement it or not. Consider my 'request' as a suggestion only.
Unicode filename handling is implemented in latest version 1.0.2 -- mostly `CreateFile` and `Get/SetFileAttributes` are checking for unicode FS support.
It turns out zip file format has an extension for unicode filenames that 7-zip supports through `-mcu` parameter. I just also updated the sample showing how to set this parameter for creating unicode zips.
cheers,
</wqw>
-
Mar 11th, 2014, 09:19 PM
#13
Lively Member
Re: [VB6] 7-zip support
wqweto, There is still a solution for std exe-project? With linking the library everything works fine. But, for me important to have a project without additional libraries
I also tried to add your code to my project. In the IDE, all works fine, but after compiling unpacking archive does not go.
If i try to use the same function as in the IDE, the program crashes
Last edited by Romeo91; Mar 11th, 2014 at 09:25 PM.
-
Mar 12th, 2014, 03:05 PM
#14
Re: [VB6] 7-zip support
Originally Posted by Romeo91
wqweto, There is still a solution for std exe-project? With linking the library everything works fine. But, for me important to have a project without additional libraries
I also tried to add your code to my project. In the IDE, all works fine, but after compiling unpacking archive does not go.
If i try to use the same function as in the IDE, the program crashes
Are you aware of regfree-COM?
Using that you can ship your OCXes and Dlls alongside your compiled executable
for true XCopy-deployment of your App-Folder.
Olaf
-
Mar 13th, 2014, 02:42 AM
#15
Lively Member
Re: [VB6] 7-zip support
I am creating a standalone-application (as portable). No installation and registration of components. From external files I only resources (language files and images). But while I use 7za.exe to work with 7z-archives
But it is an external application, not a library, and it does not have the ability to manage. The result of the application only error code. Implementation progress either.
While there is no desire to link VszLib.dll, since added another library to 7z.dll
Source code is accompanied by more difficult as you need to edit VszLib to add new features. Distribute the application will be more difficult as the final version of the library on the client side can be different
-
Mar 13th, 2014, 06:05 AM
#16
Re: [VB6] 7-zip support
Originally Posted by Romeo91
I am creating a standalone-application (as portable).
Yep - directly running from e.g. an USB-Stick without any Setup - I know...
But this App is enclosed in an AppFolder on your USB-Stick e.g.:
[MyApp]
.... MyApp.exe
.... 7z.dll
.... [MyImageResources]
.... [MyLanguageResources]
So, where exactly (since you said, it works with the checked-in reference to the AX-Binary)
is the problem with putting also VszLib.Dll beside MyApp.exe and 7z.dll, and use it within
your App without registering it (or touching the registry at all)?
If you make (binary-compatiblility-breaking) changes on the COM-Interface of VszLib -
then rename the Project-Internal LibName to VszLib2 - and compile the new Dll
(with its new interface) to VszLib2.dll - then again - just place it (when deploying
your new version) beside your Exe - it will not collide with an existing VszLib.dll.
Your USB-Stick-Folder could then look like:
[MyApp]
.... MyApp.exe
.... 7z.dll
.... VszLib.dll
.... VszLib2.dll
.... [MyImageResources]
.... [MyLanguageResources]
And you could even reference and use both VszLib-Versions within your
MyApp-Exe at the same time - as said, no registering would be needed,
when you use the right tools (either manifest-based SxS-COM-instancing -
or when you have to support machines below XP-targets, then DirectCOM.dll
can be used as well, to accomplish your regfree - and earlybound! - instancing).
Olaf
-
Mar 13th, 2014, 09:55 AM
#17
Lively Member
Re: [VB6] 7-zip support
Is it possible to place the library is not next to a file in a subdirectory?
To get just such a structure.
[MyApp]
.... MyApp.exe
.... [Tools]\7z.dll
.... [Tools]\VszLib.dll
.... [Tools]\VszLib2.dll
.... [Tools]\[MyImageResources]
.... [Tools]\[MyLanguageResources]
7z.dll i can put in subfolder, vszlib has init procedure which specifies the location of the library.
But what about the library vszlib.dll?
-
Mar 13th, 2014, 03:40 PM
#18
Re: [VB6] 7-zip support
You can put everything into a \Bin\ or a \Tools\ folder of course - in fact that's the way to go,
because it avoids (in case of OCXes) any attempts of a VB6-compiled -Executable, to try to
dynamically register any OCXes it may find in its App.Path (it does this unasked and automatically
only for OCXes, not for ActiveX-Dlls - but that's not regfree-COM, but a dynamic registering-
attempt which could cause all kind of troubles on your system, when it succeeds, which is
mostly not the case anymore on System >= Vista due to UAC)
So, yeah - a separate SubFolder for your Binaries is definitely a good idea.
See also this thread here:
http://www.vbforums.com/showthread.p...=1#post4476329
As for usage of e.g. DirectCOM.dll for regfree-purposes:
There's an example how to use it on a Bin-Subfolder... On:
http://vbrichclient.com/#/en/Demos/GUI/
And there, the MandelBrotThreaded.7z (1.6MB) archive...
For your own regfree purposes you will not need the vbRichClient5.dll or the vb_cairo_sqlite.dll -
just the small DirectCOM.dll is enough - just make sure that DirectCOM.dll is contained in
your \Tools\ Folder alongside all other Dlls - and then preload DirectCOM.dll per LoadLibrary,
as shown in the Mandelbrot-Demo, before you make use of its GetInstance-Function.
Olaf
-
Mar 31st, 2014, 03:02 PM
#19
Re: [VB6] 7-zip support
@Romeo91: Unfortunately VszLib is not as stable as I would like it to be even as separate ActiveX DLL. 7-zip does not use COM multi-threading and VB6 has troubles with COM multi-threading let alone when COM is even not initialized on new threads. I don't think I can debug the issues with the current version of VszLib anymore.
The way I see it for all-VB6 wrapper component that can be using in Std EXEs is VB6+ASM. The multi-threading part has to injected ASM or always remain plagued with issues. (For instance current VszLib cannot produce RARs for whatever reason)
cheers,
</wqw>
-
Aug 16th, 2014, 01:45 AM
#20
New Member
Re: [VB6] 7-zip support
Hi, we are planning starting some small VB6 implementation of a C++ propiertary set of DLLs. Basically at some point, we have to compress a set of files, produced by our own dlls, for which your <VszLib.dll> does an amazing work and saves having to code our GUI-based sample in something like C++ or C#, which is painful. We don't plan running any multi-thread or anything.
However, we have two questions. I've read VszLib.dll is not working well when being called from a compiled .exe. Can you please confirm is it the case even on a very small, single-threaded usage as we plan to do? It's important, because we will be distributing this demo and it will have to include both, your VszLib.dll and 7z.dll
Finally, please confirm if we have to accompany our demo with both, \src folder and 7-Zip source code. As far as I read both ar GNU/LGPL
Thanks
Diego
Originally Posted by wqweto
@Romeo91: Unfortunately VszLib is not as stable as I would like it to be even as separate ActiveX DLL. 7-zip does not use COM multi-threading and VB6 has troubles with COM multi-threading let alone when COM is even not initialized on new threads. I don't think I can debug the issues with the current version of VszLib anymore.
The way I see it for all-VB6 wrapper component that can be using in Std EXEs is VB6+ASM. The multi-threading part has to injected ASM or always remain plagued with issues. (For instance current VszLib cannot produce RARs for whatever reason)
cheers,
</wqw>
-
Jan 30th, 2015, 01:33 PM
#21
Re: [VB6] 7-zip support
@diegosendra: I'm using VszLib.dll in some of my compiled applications to compress/extract .7z archives with no problems as of now. Still some other formats are not stable enough (e.g. .rar support) but I don't plan on debugging these anymore.
For LGPL (Lesser GPL) you can redistribute binary .dll in your closed source application just fine. Even attribution in about box is optional.
The fun starts when you want to add features upon my source code -- you have to open source your new functionality as I did in first place. If you are not recompiling the library you are safe to redistribute VszLib in only binary, only source or both with your closed/open source solution.
HTH,
</wqw>
-
Apr 8th, 2015, 04:07 PM
#22
Fanatic Member
Re: [VB6] 7-zip support
property Get FileInfo in cVszArchive Class does not work as intended.
Originally returns only array of first file info.
Here is sample how to get filename(s) from compressed volume ie. .7z or other compressed file supported by 7-zip.
Property Get FileInfo(ByVal FileIdx As Long) As Variant
If FileIdx >= 0 And FileIdx < m_lCount Then
With m_uFiles(FileIdx)
'FileInfo = Array (.FileName, .Attributes, .Size, .Encrypted, .Crc, .Comment, .CreationTime, .LastAccessTime, .LastWriteTime)
FileInfo = m_uFiles(FileIdx).FileName
End With
End If
End Property
-
Apr 8th, 2015, 04:09 PM
#23
Fanatic Member
Re: [VB6] 7-zip support
Originally Posted by Tech99
property Get FileInfo in cVszArchive Class does not work as intended.
Originally returns only array of first file info.
Here is sample how to get filename(s) from compressed volume ie. .7z or other compressed file supported by 7-zip.
Property Get FileInfo(ByVal FileIdx As Long) As Variant
If FileIdx >= 0 And FileIdx < m_lCount Then
With m_uFiles(FileIdx)
'FileInfo = Array (.FileName, .Attributes, .Size, .Encrypted, .Crc, .Comment, .CreationTime, .LastAccessTime, .LastWriteTime)
FileInfo = m_uFiles(FileIdx).FileName
End With
End If
End Property
to clarify comment and replace line
'FileInfo = Array (.FileName, .Attributes, .Size, .Encrypted, .Crc, .Comment, .CreationTime, .LastAccessTime, .LastWriteTime)
with
FileInfo = m_uFiles(FileIdx).FileName
-
Apr 11th, 2015, 02:11 PM
#24
Re: [VB6] 7-zip support
Originally Posted by Tech99
property Get FileInfo in cVszArchive Class does not work as intended.
Originally returns only array of first file info.
It returns file info based on the parameter `FileIdx` -- that's what `With m_uFiles(FileIdx)` is about. You can get the file name by accessing the first element of each array like this: `sMyFileName = FileInfo(lIdx)(0)` will return the file name of file with index `lIdx`.
cheers,
</wqw>
-
Oct 21st, 2017, 10:56 AM
#25
New Member
-
Oct 22nd, 2017, 04:30 AM
#26
Re: [VB6] 7-zip support
Hi RelaAlterEgo,
What output format do you produce? What version of 7-zip SDK do you use? Show some code around CompressArchive method call if possible.
I'm using VszLib with companion 7za.dll version 9.22 in production to compress DB backups larger than 5MB w/ no problems so far.
cheers,
</wqw>
-
Oct 23rd, 2017, 04:15 AM
#27
New Member
Re: [VB6] 7-zip support
Originally Posted by wqweto
Hi RelaAlterEgo,
What output format do you produce? What version of 7-zip SDK do you use? Show some code around CompressArchive method call if possible.
I'm using VszLib with companion 7za.dll version 9.22 in production to compress DB backups larger than 5MB w/ no problems so far.
cheers,
</wqw>
Hi wqweto, and thanks for quick reply!
Output format is 7zip archive (.7z) and i don't install any 7-zip SDK source, i only downloaded 7zip packages on official site, copy 7z.dll or 7za.dll into src folder inside your sample project; setting compression level to ultra (switch -mx9), when i try to compress an xml file of 5.5mb with 9.20 dll version, vb application hangs, while with fastest or fast compression (-mx1 or -mx3) works...If i don't set 'm' parameter application hangs, too. Tried with latest 7z.dll / 7za.dll 16.04), hangs hovewer, omitting parametter setting or with -mx1 and -mx3, too.
This is code i use:
Code:
Private Sub cmdCompress_Click()
With New cVszArchive
.AddFile App.Path & "\database.xml" 'XML FILE SIZE=5.5MB
'NOTE: OMITTING FOLLOWING INSTRUCTION CAUSE APPLICATION HANGING WITH BOTH 7z/7za.dll 9.20 AND 7z/7za.dll 16.04 ON CompressArchive CALL
.Parameter("x") = 3 '-- CompressionLevel = Fast - WORKING WITH 7z/7za.dll 9.20, HANGING WITH 7z/7za.dll 16.04 ON CompressArchive CALL
'.Parameter("x") = 9 '-- CompressionLevel = Ultra - HANGING WITH BOTH 7z/7za.dll 9.20 AND 7z/7za.dll 16.04 ON CompressArchive CALL
.CompressArchive App.Path & "\test.7z"
End With
MsgBox "test.7z created ok", vbExclamation
End Sub
Again, thanks!
-
Dec 10th, 2018, 09:39 AM
#28
Fanatic Member
Re: [VB6] 7-zip support
Currently does not extract .rar packages. Vszlib reports .Filecount as zero (0) for rar package.
7z.dll version 18.5.0.0 (18.4.2018)
Code:
With New cVszArchive
.Init Makepath(App.Path, "7z.dll")
.OpenArchive SevenZipFile 'file name tested test.rar
Debug.Print .FileCount
.Extract App.Path & "\Unpacked"
End With
7zip file manager opens and extracts rar file OK.
-
Dec 10th, 2018, 09:50 AM
#29
Re: [VB6] 7-zip support
@Tech99: I haven't tweaked this project past 7-zip 9.22 and it degraded even further with each new version of the parent project.
The original effort was plagued with threading problems I'm unable to resolve and unwilling to debug further.
An idea I have is for the I/O class to be rewritten in VbRtcc if possible.
cheers,
</wqw>
-
Dec 10th, 2018, 03:09 PM
#30
Fanatic Member
Re: [VB6] 7-zip support
Originally Posted by wqweto
@Tech99: I haven't tweaked this project past 7-zip 9.22 and it degraded even further with each new version of the parent project.
The original effort was plagued with threading problems I'm unable to resolve and unwilling to debug further.
An idea I have is for the I/O class to be rewritten in VbRtcc if possible.
cheers,
</wqw>
Thanks wqweto, looked your VbRTcc project - very interesting, however found it quicker to modify app by calling 7z.exe using CreatePipe, CreateProcessA, Readfile functions (ie. getting stdout response from 7z.exe).
btw. That problematic rar file was rar5 format.
-
Feb 3rd, 2019, 08:26 AM
#31
Hyperactive Member
Re: [VB6] 7-zip support
i opened the file "test.tar.gz" and i get a filecount=1 but .fileinfo(1) with the name of the tar-file is empty.
using .Extract App.Path & "\Unpacked" creates a file with the corrrect tar-file-name but 0 bytes.
any idea how to fix that?
btw: the original 7zip-app can open the file "test.tar.gz" and list the name of the tar file and further list all the files inside the tar file.
-
Feb 3rd, 2019, 08:52 AM
#32
Re: [VB6] 7-zip support
Try using 7z.dll from 7-zip version 9.22 not the latest.
This might still not work though. . .
Did you know there is built-in tar.exe in latest versions of Win10?
Use c:> tar -czf d:\temp\aaa.tar.gz *.json to compress.
Use c:> tar -xzf d:\temp\aaa.tar.gz to uncompress.
cheers,
</wqw>
-
Feb 4th, 2019, 04:04 AM
#33
Hyperactive Member
Re: [VB6] 7-zip support
i downloaded the 7z package v9.22 and used the older 7z.dll with your test project but the file name if still empty:
but with "extract" i can extract the tar file from inside the gz file with the correct filename!
any ideas whats wrong here?
-
Feb 24th, 2019, 05:05 AM
#34
Re: [VB6] 7-zip support
Originally Posted by Mith
any ideas whats wrong here?
This is by design. GNU zip (the .gz extension) file format is a single file compression format that does *not* store original filename/date or any other info. The original filename by convention is everything before the .gz suffix, i.e. in your case the openfp-1.3.2(1).tar is the best guess what target filename should be.
After decompressing the .gz to a .tar you can use 7-zip to untar this "tape archive" to a destination folder. TAR file format includes files and directories structure in contrast to .gz and that's why both of these are used in tandem to create "solid" archives of whole directories of files.
cheers,
</wqw>
p.s. Sorry for the late reply.
-
Mar 29th, 2020, 08:53 PM
#35
Re: [VB6] 7-zip support
dear wqweto:
i have 4 questtions:
how to add folder to make a "*.7z" file?
how to Add comment text?
how to Extract a file to byte() like:dim buffer() as byte
how to check *.7z file have password?
thank you for your help
-
Mar 30th, 2020, 02:55 AM
#36
Re: [VB6] 7-zip support
> how to add folder to make a "*.7z" file?
You want to make a single 7z file with the contents of a folder or compress each file in a folder to a separate 7z archive?
Take a look add the AddFile(File As String, [Name As String], [Comment As String]) As Boolean method. File is the filename on disk e.g. c:\path\tp\myfiles.doc while the optional Name is the name this file will get in the archive e.g. myfolder/report.doc and Comment is an optional text associated w/ the entry (which might not be supported by all archive types).
> how to Extract a file to byte() like:dim buffer() as byte
Nothing built-in. (This is not as versatile as the ZipArchive class.)
> how to check *.7z file have password?
7-zip has a very rudimentary way to check archive password. If a password is required for an operation (list, extract, whatever) it raises an error with "Data Error. Wrong password?" error message. Have to capture this and provide value in Password property.
cheers,
</wqw>
-
Mar 30th, 2020, 07:35 PM
#37
Re: [VB6] 7-zip support
My question now is:
I want to generate a 7z or zip format compressed file, open it to show the comments, not for each file comments.
In addition, if you can directly add the entire directory, into a compressed file is the best.
This I can also achieve through the code.
Now the question is, how do I add an empty folder to the zip file?
Can you upgrade it to support the revision of compressed files, delete the inside part of the document, folder.
Also whether you can set the file list does not display, only enter the password can be displayed.
What's the easiest way to check if a zip file has a password?
Instead of unzipping the file and receiving an error message that contains a password.
The translation software is not accurate, attach the original Chinese:我现在的问题是:
我要生成一个7z或者zip格式压缩文件,打开之后就显示注释,不是针对每个文件的注释。
另外如果可以直接添加整个目录,变成一个压缩文件就是最好了。
这个我也可以自己通过代码实现。
现在问题是,如何添加一个空文件夹到压缩文档?
可不可以升级一下,支持修改压缩文件,删除里面的部分文件,文件夹。
另外是否可以设置不显示文件列表,只有输入密码才可以显示。
有什么最简单的方法检测一个压缩文件是否有密码?
而不是通过解压文件收到错误信息才能知道包含了密码。
-
Mar 31st, 2020, 04:20 AM
#38
Re: [VB6] 7-zip support
You are on your own to implement any or all of these requirements. If you find any issues with the project feel free to share them here.
Good luck!
</wqw>
-
Mar 29th, 2021, 11:11 AM
#39
-
Mar 29th, 2021, 12:34 PM
#40
Re: [VB6] 7-zip support
Originally Posted by L'mars
Hello WQWETO
Can your code be used to create tar files?
I have the problem of packing multiple XML files with TAR format.
I am using the language Visual Basic 6, with which I create from one to less than 500 XML files, to later want to pack them with the TAR format, generating a file called package.tar, which in turn I will have to compress with GZIP to finally build a file called package.tar.gz
I tried the code of this website https://github.com/wqweto/VszLib, but I can only create files called package.7z
Or do you know other ways to do it, for example with dll libraries made with C++?
Thanks for the space to consult you.
I don't think 7-zip has support for *compressing* in tar.gz format, most probably only extraction is available.
The good news is there is a copy of tar.exe utility bundled with every instance of Windows 10 already since a couple of years now, so you have to figure out its command-line options only :-))
Try this:
C:\> tar -cvzf C:\TARS\sqlbackup.tar.gz *.sql
cheers,
</wqw>
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|