Does anyone have any kind of module, class module, etc. that can compress files using ZIP compression?
Printable View
Does anyone have any kind of module, class module, etc. that can compress files using ZIP compression?
vbAccelerator.com has a freeware zip library; though I don't believe it's been written in VB6... :)
No it's not (well not completely) - it's just a wrapper for infozip.dll - same dll winzip's using.
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.
Not much help here, very likely you just have to code it by yourself.
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.Quote:
Originally Posted by RhinoBull
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).
I don't really like, Merri, the way you express yourself so next time watch it.Quote:
Originally Posted by Merri
Anyway, there were plenty of attempts in VB but non of them succeeded - whould that mean anything to you at all ???
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.
No, we are not equal and next time you call me lying - watch it ... Also, why don't you give it the try smarty ...
If there is none, can someone please give me the function for the best compression that you know of?
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.
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.
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 ;)
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.
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.
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.
Yes, like:Quote:
there also some other good compression stuff on the site as well.
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 ;-)
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. :wave:
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.Quote:
Originally Posted by rm_03
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.
That's correct.Quote:
Originally Posted by Merri
That's where the problem resides.Quote:
Originally Posted by Merri
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.
I would enjoy it more if someone proves me wrong, though.
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:
All the pdf file will be zip to one zip file called myZip.zipCode:C:\wzzip C:\myZip.zip C:\*.pdf
Best Regards,
ERAN
I hope you will enjoy this :)Quote:
Originally Posted by RhinoBull
1) Download the project from the link I posted.
2) Open cls_Zip.cls.
3) Add the following type:
4) Overwrite the "pack" function with the following:Code:Private Type Pack_Helper_Type
valid As Long
CRC32 As Long
USize As Long
CSize As Long
offset As Long
End Type
Example on how to use this function: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
I've done this in about 1 1/2 hours, so you can only add files to the root.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
You want a feature, add it. ;)
/edit: Oups, I forgot, you have to add the Deflate module from DreamVB`s link.
That proves nothing more than the fact that you can create files in VB.
I don't get it...Quote:
Originally Posted by RhinoBull
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...
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).
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 :)Quote:
Yeah, I also dislike using external files.
I hope this helps. :)
Come on guys, don't fight because of some bytes and bits!
Share your knowledge!
Technically, 1 less would make a difference :pQuote:
Originally Posted by Devion
chem
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.Quote:
this is childish ,silly and stubborn
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. :wave:
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
Getting a neg rep from this.. mmh.. I'll refrain from saying something stupid ;)
Anyway; VB can use asm optimized code also so that wouldn't be a issue. If we are going for a really pure without any api's etc version of a unzipper/zipper mmh.. it would be slow on large files but it's still doable :)
I'd like to see someone attempt this, then I could try and port it to ASM :D
chem
I'll take the challenge :-)
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
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.Quote:
Originally Posted by RhinoBull
The time you are busy making it in asm you get back by the fast computations done :)Quote:
Originally Posted by Merri
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.
Actually you can use a sorta inline asm in VB6, Seen it somewhere in a CRC32 class..
Yeah, I know it too, but it is a trick and not really inline in the real meaning of the word :)
Compiled asm I assume? :)
Yup, compiled. You just put it in a byte array or similar and then edit memory so that a certain procedure points to the start of the array instead of the actual procedure... I haven't done it myself so I'm not too familiar with the details. I might be a bit wrong, don't really know.
jian2587: still to make it more clear: you can't make archive program of comparable speed using pure VB6 code only. You can't do that in C/C++ either, so it isn't really an issue. You can make a archive program of comparable speed if you use ASM optimized code to help you. But then we can start wondering why to make an archive program if there are great programs out there already? So... it would be more like a feature addition to a special program and there it is all the same if one will use ASM or VB6 to do it, if VB6 code is fast enough.
Wonder how long it'll take until we're fully offtopic! :)
Edit One last thing: having arguments is never pointless ;)
But it might be a very nice way of having an internal ZIP class that's reasonably fast mmh? :)
No, wasn't me. I don't like that rep stuff.Quote:
probably rm_03 - sorry if not
Well, on the one hand, we can now create deflated ZIP archives from pure VB. :afrog: .Quote:
I should've had said "lousy performer" in this regards instead, well ... perhaps ...
On the other hand you could've avoided a lot of confusion and anger...
BTW, I bet, with compression method 0 (STORE) I could beat Winzip. :)
Huh? Look at dreamvbs link... Deflate algorithms... ZIP compression method 8... >> pure VB.Quote:
RhinoBull said what he said, because the code given doesn't prove the original argument; that VB can write ZIP compression in PURE VB.
You'll find an Add-In on PSC ("Thunder VB") which will allow you to use inline ASM.Quote:
VB6 is of course out of the list, though you can still use the ASM optimized DLL.
//edit: @Rinobull: One more thing:
The question was: "Code to compress a file with ZIP compression",
not: "Code to compress a file with ZIP compression and Winzip speed and all that stuff".
I also never intended to create a perfect Winzip clone,
I just showed that creating a ZIP file in VB is possible, >with compression<.
(BTW, ZIP compression is the wrong term - ZIP files support many algorithms),
whereas you first said: "It can't be done in VB", and you didn't say anything about speed.
That was pretty strange.
Of course VB can't reach the speed of C and pure ASM. It is taken for granted that you should not use this for a commercial archiving software...
But having a class to create and extract ZIP archives for the own program is handy IMO.
You don't have to ship a big DLL for extracting some small files.
Do you guys mind to stop quoting me, it's enough already. Thanks. :wave:
You weren't asking for help if I remember rightly, it was some comment like "I can't do it right now but someone else try it".Quote:
Originally Posted by inventrex
I don't want to get drawn into any argument, but if you post in a thread and take part in a discussion, then others have a right to quote you ;) IMO.Quote:
Originally Posted by RhinoBull
Quote:
Originally Posted by Devion
No editing memory needed. As you said, place the precompiled ASM opcodes into a byte array, and use CallWindowProc() to call the procedure. You need to make sure it pops four arguments because that is how many CallWindowProc passes.Quote:
Originally Posted by Merri
You also could overwrite a dummy function directly with the ASM or with a JMP instruction to the ASM.Quote:
Originally Posted by penagate
Yah, but you need the ASM first, to do that :D
so far as I have seen, precompiled opcodes are the only way to do it. Maybe if you edited the .obj file, but that's overly complex, when this way works ;)
Cheat :pQuote:
Originally Posted by rm_03
Guys, this thread is for Zip Compression not skull-bashing, use the chit-chat area :)
Edit: Good boys! Here's a cookie :D
Inventrex, I have no idea what that link has to do with the rep I gave you. If you wish to discuss this further then please use the PM system.
OK, it's fine. Since I don't get what you meant, I'll just delete my useless posts and reduce clutter.
Firstly, making a zip extractor + compressor is possible! Though quite impractical if not coded with very much care for optimization! Now those who say it cant let me tell u that there has been written a class that can completely decode a jpg file using pure vb! What is a jpg file its basically a 'compressed' picture file! This code uncompresses the file then loads the data! I myself am trying to make a mp3 decoder now a days in pure vb! But as others said we have performance issues! My code takes a loooooong time to only load the mp3 file in binary format! I took the smallest song i can find only 500 kbs and it took like a minute to load on my p4 2.2 ghz! But the jpg compressor is working wonders with lighting fast performance! So making a compressor/extractor is possible but quite impractical cause mp3s and .zips/.rars are files huge in size for vb! So its rather impractical but at the same place it is certainly possible!
Can someone extract the LZW dynamic with hashing code for me? Or is anyone thinks that there is a better compressor for executables, please give me that code.
Are you talking about actually loading the file into memory? If that takes a minute you are not optimizing your code ;) (Open 'File' for Input as #1?)Quote:
I took the smallest song i can find only 500 kbs and it took like a minute to load on my p4 2.2 ghz!
Ok now forgot to mention one thing there (oooops)! Its opening the file as binary taking the value by get function and displaying it in a text box! The displaying code just blows away the speed! I remove the displaying stuff then its really fast so had to mention dat but forgot! So r u guys here planning to make one zip compressor/decompressor or just like talking about it?
Not sure; I'd be willing to give it a try to make a class-based ZIP/UNZIP.. (Winzip 9 compatible would also require some encryption/decryption routines).
Wohoo, that'll be a great MP3 decoder.Quote:
Originally Posted by RapchikProgrammer
You may read the whole 2 pages of this thread, and check all the posted links.Quote:
Originally Posted by RapchikProgrammer
Especially the ones by me and dreamvb.
I also attached my complete deflated ZIP creator project (compile it before using and only compress small files (or use compression level 0), the deflate algorithm sucks!).
P.S.: The zip was created by it :)