|
-
Aug 20th, 2005, 07:03 PM
#1
Thread Starter
Hyperactive Member
ZIP Compression Using Pure Visual Basic
Does anyone have any kind of module, class module, etc. that can compress files using ZIP compression?
-
Aug 20th, 2005, 07:15 PM
#2
Fanatic Member
Re: ZIP Compression Using Pure Visual Basic
vbAccelerator.com has a freeware zip library; though I don't believe it's been written in VB6...
Author for Visual Basic Web Magazine
-
Aug 20th, 2005, 07:23 PM
#3
Re: ZIP Compression Using Pure Visual Basic
No it's not (well not completely) - it's just a wrapper for infozip.dll - same dll winzip's using.
-
Aug 20th, 2005, 08:02 PM
#4
Thread Starter
Hyperactive Member
Re: ZIP Compression Using Pure Visual Basic
I already know about those. I'm trying to find a module, class module, etc. for it. I don't like using dlls and ocxs.
-
Aug 20th, 2005, 08:11 PM
#5
Re: ZIP Compression Using Pure Visual Basic
Not much help here, very likely you just have to code it by yourself.
-
Aug 20th, 2005, 08:12 PM
#6
Re: ZIP Compression Using Pure Visual Basic
VB isn't capable of doing such stuff on its own - you must use some library and the one from vbAccelerator comes very handy (also full source is available). So, if you don't like it then you pretty much on your own.
-
Aug 20th, 2005, 08:23 PM
#7
Re: ZIP Compression Using Pure Visual Basic
 Originally Posted by RhinoBull
VB isn't capable of doing such stuff on its own - you must use some library and the one from vbAccelerator comes very handy (also full source is available). So, if you don't like it then you pretty much on your own. 
Err... don't push out such lies so easily. VB can do it very well (like about any other programming language out there), nobody just haven't bothered to do it since there are already-made solutions available.
inventrex: the easiest solution is just to use external DLL. Can't really rely that a user has Windows XP or WinZip (I use IZarc and have disabled WinXP's own ZIP functionality in my other computer).
-
Aug 20th, 2005, 08:32 PM
#8
Re: ZIP Compression Using Pure Visual Basic
 Originally Posted by Merri
Err... don't push out such lies so easily. VB can do it very well (like about any other programming language out there), nobody just haven't bothered to do it since there are already-made solutions available. ...
I don't really like, Merri, the way you express yourself so next time watch it.
Anyway, there were plenty of attempts in VB but non of them succeeded - whould that mean anything to you at all ???
-
Aug 20th, 2005, 08:39 PM
#9
Re: ZIP Compression Using Pure Visual Basic
I don't like your way either so we're equal on that. On the topic: it just means not everyone have the skills to do it; ZIP format is pretty feature rich as it is. ZIP File Format Specification has a lot of text in it.
-
Aug 20th, 2005, 08:48 PM
#10
Re: ZIP Compression Using Pure Visual Basic
No, we are not equal and next time you call me lying - watch it ... Also, why don't you give it the try smarty ...
-
Aug 20th, 2005, 09:06 PM
#11
Thread Starter
Hyperactive Member
Re: ZIP Compression Using Pure Visual Basic
If there is none, can someone please give me the function for the best compression that you know of?
-
Aug 21st, 2005, 01:07 AM
#12
Re: ZIP Compression Using Pure Visual Basic
Here is the full link to the zip page on vbAccelerator.
IMO, you could write it yourself in VB fairly straightforwardly, all you need to do is learn the algorithm (compression method) and just code that.
-
Aug 21st, 2005, 01:09 AM
#13
Thread Starter
Hyperactive Member
Re: ZIP Compression Using Pure Visual Basic
I already tried that but I don't know like using dlls or ocxs. I'm just a beginner, so I need to see as much code examples as possible.
-
Aug 21st, 2005, 01:20 AM
#14
Re: ZIP Compression Using Pure Visual Basic
DLLs are good, they reduce the amount of code you have to write yourself... If you're just a beginner you should learn how to use DLLs and OCXs instead of just ignoring them. Trust me, eventually you won't be able to work without them, so better to start using them earlier
-
Aug 21st, 2005, 01:25 AM
#15
Thread Starter
Hyperactive Member
Re: ZIP Compression Using Pure Visual Basic
It just doesn't seem right using dlls and ocx created using C++ in a Visual Basic project. I'm sure that Visual Basic can do as much as C++ can, but no one wants to give away any of their source codes.
-
Aug 21st, 2005, 01:29 AM
#16
Re: ZIP Compression Using Pure Visual Basic
Well, if you find any. I believe Rhino when he says that people have tried and failed, although I'm more inclined to believe they gave up 
As I said, you could do it yourself. There isn't source code for everything.
And BTW, VB can do pretty much as much as C++, but the more you get out of the VB "comfort zone" and into more advanced topics, the more roundabout and fiddly code you are gonna need.
-
Aug 21st, 2005, 05:52 AM
#17
Hyperactive Member
Re: ZIP Compression Using Pure Visual Basic
Well I not seen any code as yet that can Create Zip files from VB Code. Tho I did once find an Opensource VB Program that allows you to extract from Zip files, but that not you want is it.
I did come accross this tho
Deflate64/Inflate64 for coders
http://www.pscode.com/vb/scripts/Sho...58473&lngWId=1
there also some other good compression stuff on the site as well.
When your dreams come true.
On error resume pulling hair out.
-
Aug 21st, 2005, 10:55 AM
#18
Lively Member
Re: ZIP Compression Using Pure Visual Basic
there also some other good compression stuff on the site as well.
Yes, like:
http://www.pscode.com/vb/scripts/Sho...53174&lngWId=1
/edit:
BTW, where does all this "VB can't do this, use C!!" stuff come from?
The only things VB can't do is drivers, safe multi threading (at least as standard EXE) and direct low level IO.
And creating ZIP files is far away from being low level ;-)
Last edited by rm_03; Aug 21st, 2005 at 11:06 AM.
-
Aug 21st, 2005, 11:40 AM
#19
Re: ZIP Compression Using Pure Visual Basic
I understand I flamed this thread abit, HOWEVER I will be proven wrong ONLY if someone shows me a really working example of "creating zip file using pure any pre dot net vb" and it has to perform just like Winzip, RAR, PKZip and/or some others do - it could better but not lousy. Until then it's all going to be speculations. Sorry.
-
Aug 21st, 2005, 12:06 PM
#20
Re: ZIP Compression Using Pure Visual Basic
 Originally Posted by rm_03
BTW, where does all this "VB can't do this, use C!!" stuff come from?
It comes from the 90's when C++ got a lot of fanboys and they bashed VB all they could. Atleast, that is one of the main reasons.
Rhino: what you're trying to say is that VB couldn't handle reading and writing a file. A ZIP is a file, thus is made of bits. You can handle bits with VB (And, Or, Xor, bitshifting with some trick code). Reading and writing a ZIP file is just converting data from a format to another.
You can find a JPEG compressor over at PSC, which saves JPG files. Also, I've made a MIX file reader and writer using VB: MIX files are from Command & Conquer, which is a archive format without actual compression by the file format itself as the contents that were stored were already compressed; which is very much like ZIP. ZIP compresses individual files and acts otherwise as an archive. Too bad I lost the source for that when my harddisk failed a few years ago... not that C&C or Red Alert would be interesting these days.
I have also made a Settlers II map reader and writer which contains multiple map data for a single map... quite similar to archive file, though lacks details for filenames. For Transport Tycoon I have a reader for GFX files (contains multiple compressed graphics files), though I never got as far as writing the code for saving a file. I could have.
These should be enough to proof ZIP file reading and saving can be done with VB. WinZip, PKzip and the like use ASM optimized code, so you just can't beat them with higher level languages no matter what you do. You could make the speed quite good though.
-
Aug 21st, 2005, 12:29 PM
#21
Re: ZIP Compression Using Pure Visual Basic
 Originally Posted by Merri
... A ZIP is a file, thus is made of bits. You can handle bits with VB (And, Or, Xor, bitshifting with some trick code). ...
That's correct.
 Originally Posted by Merri
... Reading and writing a ZIP file is just converting data from a format to another. ...
That's where the problem resides.
-
Aug 21st, 2005, 01:04 PM
#22
Re: ZIP Compression Using Pure Visual Basic
Right. Believe it as you wish, for the sake of having a differing opinion. I haven't seen anything that proves against. "That's where the problem resides" doesn't really tell why there would be a problem or why VB couldn't do it.
Enjoy your "I won!" dance, won't comment on this any more.
The Proof: "This code can be used to create filetypes wich used Deflate as compression algo (ZIP,GZIP,CAB, etc.etc)" (mentioned earlier in this very thread)
Edit Fixed typo.
Last edited by Merri; Aug 21st, 2005 at 02:43 PM.
-
Aug 21st, 2005, 01:13 PM
#23
Re: ZIP Compression Using Pure Visual Basic
I would enjoy it more if someone proves me wrong, though.
-
Aug 21st, 2005, 02:57 PM
#24
Hyperactive Member
Re: ZIP Compression Using Pure Visual Basic
Reply to abazabam,
Hello abazabam,
You can try winzip Comand line
download this 2 files from http://www.winzip.com/downcl.htm
1)WinZip 9.0
2)Command Line Support Add-On 1.1 SR-1
than read the documentation about Command Line Support Add-On 1.1 SR-1
i wrote a VB code using a batch file:
VB Code:
Call Shell("C:\myBatch.bat", vbMaximizedFocus)
inside myBatch i used the wwzip command:
Code:
C:\wzzip C:\myZip.zip C:\*.pdf
All the pdf file will be zip to one zip file called myZip.zip
Best Regards,
ERAN
Eran Fox
ASSEMBLER,C,C++,VB6,SQL...
-
Aug 21st, 2005, 03:34 PM
#25
Lively Member
Re: ZIP Compression Using Pure Visual Basic
 Originally Posted by RhinoBull
I would enjoy it more if someone proves me wrong, though.
I hope you will enjoy this 
1) Download the project from the link I posted.
2) Open cls_Zip.cls.
3) Add the following type:
Code:
Private Type Pack_Helper_Type
valid As Long
CRC32 As Long
USize As Long
CSize As Long
offset As Long
End Type
4) Overwrite the "pack" function with the following:
Code:
Public Function Pack(ZipName As String, files() As String, CompLevel As Integer) As Integer
Dim CentDat As Central_Header_Type
Dim helpers() As Pack_Helper_Type
Dim EndCentralSig As End_Header_Type
Dim fhIN As Integer, fhOUT As Integer
Dim i As Integer
Dim lngSig As Long, lngCenOff As Long
ReDim helpers(LBound(files) To UBound(files))
fhOUT = FreeFile
Open ZipName For Binary As #fhOUT
For i = LBound(files) To UBound(files)
If Not Trim$(files(i)) = vbNullString Then
helpers(i) = AppCompFile(fhOUT, files(i), CompLevel)
End If
Next
lngSig = &H2014B50
lngCenOff = Seek(fhOUT) - 1
For i = LBound(helpers) To UBound(helpers)
With CentDat
.CRC32 = helpers(i).CRC32
.CSize = helpers(i).CSize
.offset = helpers(i).offset
.USize = helpers(i).USize
.LenFname = Len(GetFile(files(i)))
.Method = CompLevel
.VerExt = 20
.VerMade = 20
End With
Put #fhOUT, , lngSig
Put #fhOUT, , CentDat
Put #fhOUT, , CStr(GetFile(files(i)))
Next
lngSig = &H6054B50
With EndCentralSig
.signature = lngSig
.Entries = UBound(files) - LBound(files) + 1
.TotEntr = .Entries
.CenOff = lngCenOff
.CenSize = Seek(fhOUT) - 1 - lngCenOff
End With
Put #fhOUT, , EndCentralSig
Close #fhOUT
End Function
Private Function AppCompFile(ByVal fh As Integer, ByVal file As String, ByVal level As Integer) As Pack_Helper_Type
'On Error GoTo OnError
Dim LocDat As Local_Header_Type
Dim fhIN As Integer
Dim btFile() As Byte
Dim lngSig As Long
AppCompFile.offset = Seek(fh) - 1
fhIN = FreeFile
Open file For Binary As #fhIN
ReDim btFile(LOF(fhIN) - 1) As Byte
Get #fhIN, , btFile
Close #fhIN
LocDat.USize = UBound(btFile) + 1
LocDat.CRC32 = CRC.CalcCRC32File(btFile)
Deflate btFile, level, False
With LocDat
.CSize = UBound(btFile) + 1
.LenFname = Len(GetFile(file))
.Method = level
.VerExt = 20
End With
lngSig = &H4034B50
Put #fh, , lngSig
Put #fh, , LocDat
Put #fh, , CStr(GetFile(file))
Put #fh, , btFile
With AppCompFile
.CRC32 = LocDat.CRC32
.CSize = LocDat.CSize
.USize = LocDat.USize
.valid = 1
End With
OnError:
End Function
Private Function GetFile(file As String) As String
GetFile = Mid$(file, InStrRev(file, "\") + 1)
End Function
Example on how to use this function:
Code:
Option Explicit
Dim p As New cls_Zip
Private Sub Form_Load()
Dim files(0) As String
files(0) = "C:\export.def"
p.Pack "C:\new.zip", files, 8
End Sub
I've done this in about 1 1/2 hours, so you can only add files to the root.
You want a feature, add it. 
/edit: Oups, I forgot, you have to add the Deflate module from DreamVB`s link.
Last edited by rm_03; Aug 21st, 2005 at 03:44 PM.
-
Aug 21st, 2005, 04:37 PM
#26
Re: ZIP Compression Using Pure Visual Basic
That proves nothing more than the fact that you can create files in VB.
-
Aug 22nd, 2005, 04:03 AM
#27
Lively Member
Re: ZIP Compression Using Pure Visual Basic
 Originally Posted by RhinoBull
That proves nothing more than the fact that you can create files in VB.
I don't get it...
1) The question was: code to compress a file with ZIP compression
2) You said: Can't be done in VB.
3) dreamvb posted a link to modules that show the Deflate/Inflate algorithms used in Zip files. Disproof of your statement.
4) You said you want a working example on how to create a Zip file with VB classic.
What you said with this is: You don't believe VB has arithmetic operators and can do file IO. The converse was proved just when VB was released some years ago.
5) I posted a working example on how to create the Zip file structure with compressed data in it.
6) You said: "This only proofs VB can do file IO".
Right... If VB creates a ZIP file, it's file IO.
If WinZip creates a ZIP file, it's a ZIP file.
This is ridiculous...
-
Aug 22nd, 2005, 04:11 AM
#28
Frenzied Member
Re: ZIP Compression Using Pure Visual Basic
Reading this thread reminded me of all the people saying VB didn't support pointers... 
Anyway; I agree with RM_03, VB can do pure File IO/Compression/Decompression without a problem it's just that no one actually thought about doing it due to the freeware/open source libraries available (ZLib, etc).
Yeah, I also dislike using external files.
MSVBVM60.DLL or MSVBVM50.DLL ring a bell? - In other words you'll always be depending on external files to run your projects. One more or less doesn't really make a difference
-
Aug 22nd, 2005, 04:16 AM
#29
Re: ZIP Compression Using Pure Visual Basic
I hope this helps.
-
Aug 22nd, 2005, 07:37 AM
#30
Re: ZIP Compression Using Pure Visual Basic
Come on guys, don't fight because of some bytes and bits!
Share your knowledge!
-
Aug 22nd, 2005, 07:50 AM
#31
Re: ZIP Compression Using Pure Visual Basic
 Originally Posted by Devion
MSVBVM60.DLL or MSVBVM50.DLL ring a bell? - In other words you'll always be depending on external files to run your projects. One more or less doesn't really make a difference 
Technically, 1 less would make a difference 
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Aug 22nd, 2005, 08:06 AM
#32
Re: ZIP Compression Using Pure Visual Basic
this is childish ,silly and stubborn
That's a qoute of from neg rep comments someone (probably rm_03 - sorry if not) gave me for my post in this thread (last prior to this) so it is silly to rep for an opinion. BTW, I don't really give a damn thing about it.
Anyway, that sample really proves nothing but what I previously said: there were plenty of attempts but non of them performed like Winzip, RAR or say PKZip and that's what matters. I did say that VB "isn't capable" so maybe I should've had said "lousy performer" in this regards instead, well ... perhaps ...
Also, as Merri pinted out Winzip, RAR and others use "ASM optimized code" so there is no way to beat that performance and it's a most important thing: who's going to use your pure VB compressor if it takes 30 min when it may 30 sec ... And you call that "childish ,silly and stubborn"? Stubborn maybe, but certainly not childish and/or silly.
My best regards - especially to the person who neg rep me.
-
Aug 22nd, 2005, 08:08 AM
#33
Re: ZIP Compression Using Pure Visual Basic
What he means is, the code doesn't answer the question. I don't know why many of you are finding it so hard to understand.
RhinoBull said what he said, because the code given doesn't prove the original argument; that VB can write ZIP compression in PURE VB.
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Aug 22nd, 2005, 08:10 AM
#34
-
Aug 22nd, 2005, 08:12 AM
#35
Re: ZIP Compression Using Pure Visual Basic
I'd like to see someone attempt this, then I could try and port it to ASM 
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Aug 22nd, 2005, 08:15 AM
#36
Frenzied Member
Re: ZIP Compression Using Pure Visual Basic
I'll take the challenge :-)
-
Aug 22nd, 2005, 08:40 AM
#37
Re: ZIP Compression Using Pure Visual Basic
inventrex: Have you looked at the traffic on your ports while using MSN Plus!? I have a post somewhere else which says MSN Plus, while running, sends POST (?) requests to websites which the MSN Plus creator gets paid for having visitors. You know those online things that say you get $0.50 for every person who visits this site using the link we give you? He did that. netstat -a if I remember correctly. Technically, he is being paid for the thousands of people who are using his program. Personally, I would like a massive banner across the program saying this is happening, before using an "illegal" add-on like that.
(PS: Saw the Petition in your sig)
chem
Visual Studio 6, Visual Studio.NET 2005, MASM
-
Aug 22nd, 2005, 08:44 AM
#38
Re: ZIP Compression Using Pure Visual Basic
 Originally Posted by RhinoBull
Also, as Merri pinted out Winzip, RAR and others use "ASM optimized code" so there is no way to beat that performance and it's a most important thing: who's going to use your pure VB compressor if it takes 30 min when it may 30 sec
Maybe more like 40 - 60 seconds than 30 minutes (thus somewhat identical to pure C/C++ implementation). With proper optimizations you can do "miracles". A lot of ZIP compression is just low level math which can be done real fast no matter what the language. With ASM you can just get much more control over it as there are more specific commands one can use... it just takes darn long to write it all in ASM.
-
Aug 22nd, 2005, 08:49 AM
#39
Frenzied Member
Re: ZIP Compression Using Pure Visual Basic
 Originally Posted by Merri
Maybe more like 40 - 60 seconds than 30 minutes (thus somewhat identical to pure C/C++ implementation). With proper optimizations you can do "miracles". A lot of ZIP compression is just low level math which can be done real fast no matter what the language. With ASM you can just get much more control over it as there are more specific commands one can use... it just takes darn long to write it all in ASM.
The time you are busy making it in asm you get back by the fast computations done
-
Aug 22nd, 2005, 09:04 AM
#40
Re: ZIP Compression Using Pure Visual Basic
Yeah, but the thing is... that wasn't my point. It is already done in ASM. Just go grab Info-ZIP source code and you can use it inline in any compiler that supports inline ASM (afaik). VB6 is of course out of the list, though you can still use the ASM optimized DLL. That is if you want ASM optimized. VB6 optimized would be good enough for many cases, the only time one has a special need for the most extreme speed is when you compress a lot of files (thousands) or if you compress very big files. And even then it might be the computer harddisk which cause the most slowdown, knowing the processing power of a modern computer.
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
|