Visual Basic
Using the Unzip Control
Information in this topic can be used with any program that supports using 32-bit ActiveX controls, such as Visual Basic 4 and higher, and Borland C++Builder/Delphi.
Download the Unzip Control (72KB - requires Visual Basic 5.0 runtime files)
While I was writing the Transport Tycoon Saved Game Manager, I wanted to add some sort of compressed saved game support to it. So I wrote a very minimal Unzip control (UNZIP.OCX) that did what I want and not much else. I seem to have lost the source code when my other computer's hard disk went down, but it wouldn't be hard to create a new version with more functionality. I'm planning on creating a more object-orientated compression library soon. For example, to create a zip file and add some files to it with maximum compression, you may be able to use the following code:
Dim ZipFile As Archive
Set ZipFile = OwenZip.NewArchive("C:\MyTest.zip")
ZipFile.CompressionLevel = 9
ZipFile.AddFiles "C:\Hello.exe"
ZipFile.AddFiles "C:\my.mp3"
ZipFile.Close
Please note that this is only an example of what the syntax might be like - I haven't actually written the control yet! However, Transport Tycoon Saved Game Manager 2.0 and higher contain a new compression control, OwenZIP.ocx, which supports compression and decompression in a manner similar to the original Unzip control. You are free to experiment with this if you like. I will update this page in the near future with more information. Please do contact me if you are interested in this.
The original Unzip control is listed as 'Owen Rudge's Unzip control' in the ActiveX control list. To use it, place an UnZip control on your form, and fill in the following properties:
ArchiveFile: The path and filename of the ZIP you want to extract from.
ExtractTo: The path you want to extract the files in the ZIP to.
Key: 234609248-7310867-234791-TT
If you do not set the Key property, you will receive an error saying that the control can only be used with Owen Rudge products.
This version of UnZip doesn't extract directories - as I said, it was only written to include the functionality TTSGM needed. OwenZip does however extract directories.
To unzip files, call the UnZip method, with the files you want extracted. For example:
UnZip1.UnZip "*.*"
UnZip1.UnZip "MYFILE.TXT", "MYPROG.EXE", "Hello.World!"
You can use long filenames in ZIPs. If you have any comments on this control, please e-mail me.