Jump to content
Sign in to follow this  
rasim

Zip32

Recommended Posts

rasim

Ok, after searching for easy and functional UDF for works with zip archives, i wrote Zip32 UDF. This UDF used 2 free library zip32.dll and unzip32.dll. Hope this UDF be useful for you. :P

License

Main features:

Create zip archive

Extract zip archive

Set archive comment

Read archive comment

Encrypt archive

Decrypt archive

Compression level 0-9

Include\Exclude files by date

Include\Exclude files by name

Include\Exclude files by files number

Include\Exclude system and hidden files

Update archive

Freshen archive

Test archive

And more... :P

Download Zip32 UDF

Included latest zip32.dll and unzip32.dll.

Edit:

Uploaded UDF on this site :o

zip_udf.zip

Edited by rasim
  • Like 1

Share this post


Link to post
Share on other sites
Andreik

Nice work! Just tested and work fine. I like your scripts and your UDF. Thanks rasim! :P


When the words fail... music speaks

Share this post


Link to post
Share on other sites
SmOke_N

Ok, after searching for easy and functional UDF for works with zip archives, i wrote Zip32 UDF. This UDF used 2 free library zip32.dll and unzip32.dll. Hope this UDF be useful for you. :P

License

Main features:

Create zip archive

Extract zip archive

Set archive comment

Read archive comment

Encrypt archive

Decrypt archive

Compression level 0-9

Include\Exclude files by date

Include\Exclude files by name

Include\Exclude files by files number

Include\Exclude system and hidden files

Update archive

Freshen archive

Test archive

And more... :P

Download Zip32 UDF

Included latest zip32.dll and unzip32.dll.

Just FYI, Firefox doesn't like your download site... first I've seen a big red "Warning" from them, so I had to fish around for others lol... nice little feature.

Common sense plays a role in the basics of understanding AutoIt... If you're lacking in that, do us all a favor, and step away from the computer.

Share this post


Link to post
Share on other sites
rasim

Andreik

SmOke_N

Just FYI, Firefox doesn't like your download site... first I've seen a big red "Warning" from them, so I had to fish around for others lol... nice little feature.

Several members tell me, that Firefox don't like my site where i upload my scripts. I use Opera and Firefox and i don`t get any "Warning" messages :P

I upload UDF on this site, updated first post. Thanks for feedback guys! :P

Share this post


Link to post
Share on other sites
Catdaddy

Great work!!! This will come in really handy for a variety of projects I am working on.

One small question:

When I use your example file and I set _ZipSetOptions to encrypt the ZIP file, it asks for my encryption password twice. But if I specify the password in the function without the InputBox it runs fine. Didn't know if this was something inherit with the .DLL files or AutoIt or maybe my machine is just loopy.

Also, $sJunkDir does not seem to function very well, at least not on my machine (XP SP3) (AutoIt 3.2.12.0). I get an error whenever I set this in _ZipSetOptions.

Otherwise, I really appreciate the work. Kudos.

Share this post


Link to post
Share on other sites
Garp99HasSpoken

Nice work. Good addition to the site.

;)

Share this post


Link to post
Share on other sites
rasim

Catdaddy

Garp99HasSpoken

Thanks for feedbacks guys ;)

Share this post


Link to post
Share on other sites
jbnh

Hey, so for multiple file we do like this:

$ZipFile = FileSaveDialog("New Archive", "", "Archive files (*.zip)", 2, "", $hGUI)
If $ZipFile = "" Then Exit

$FileToZip = FileOpenDialog("Add file(s)", "", "All files (*.*)", 4, "", $hGUI)
If $FileToZip = "" Then Exit

..................



$aFiles = StringSplit($FileToZip, "|")

If UBound($aFiles) > 1 Then
    For $i = 2 To $aFiles[0]
        _ZIP_Archive($ZipFile, $aFiles[1] & "\" & $aFiles[$i])
    Next
Else
    _ZIP_Archive($ZipFile, $aFiles[1])
EndIf

It's ok now for multiple files, but strangely the loop doesnt word for one file and evrything is correct. (well the box show that it suceed but the archieve isnt create). im on vista. Why?

Thanks... !

Edited by jbnh

Share this post


Link to post
Share on other sites
rasim

jbnh

Oh sorry, my miss... ;) try this:

$aFiles = StringSplit($FileToZip, "|")

If UBound($aFiles) > 2 Then
    For $i = 2 To $aFiles[0]
        _ZIP_Archive($ZipFile, $aFiles[1] & "\" & $aFiles[$i])
    Next
Else
    _ZIP_Archive($ZipFile, $aFiles[1])
EndIf

Share this post


Link to post
Share on other sites
jbnh

my mistake too, didnt saw the error. Thanks dude.

Share this post


Link to post
Share on other sites
Emiel Wieldraaijer

Yes, i thought about it.

I haven't tried it yet.. do you think it would be possible ?

Emiel


Best regards,Emiel Wieldraaijer

Share this post


Link to post
Share on other sites
Vakari

Excellent submission!

I just thought I'd mention that your example worked flawlessly on Windows 2000 sp4.

Share this post


Link to post
Share on other sites
AskThatDude

Is it possible to zip a file without including the current directory structure?

Share this post


Link to post
Share on other sites
rasim

Is it possible to zip a file without including the current directory structure?

Yes. Just create a array with the full path of files and call a _ZIP_Archive() function in the loop. :)

Share this post


Link to post
Share on other sites
Undutchable

Quote:"

Yes. Just create a array with the full path of files and call a _ZIP_Archive() function in the loop.

"

I just tried and it didn't work. (didn't build an array, just tried with a single file, I suppose it's a valid test)

$DirToZip = @TempDir & "\test.txt"

I still get a ZIP with the entire folder structure inside.

Share this post


Link to post
Share on other sites
FireNET

is it possible to print file that extract from the zip inside the status label?

my label is create from GUICtrlCreateLabel

$STATUS_LABEL_1 = GUICtrlCreateLabel("Welcome", $STATUS_LABEL_LEFT, $STATUS_LABEL_TOP, $STATUS_LABEL_WIDTH, $STATUS_LABEL_HEIGHT,$SS_CENTER)

if possible, how?

TQ

Share this post


Link to post
Share on other sites
rasim

I just tried and it didn't work. (didn't build an array, just tried with a single file, I suppose it's a valid test)

$DirToZip = @TempDir & "\test.txt"

I still get a ZIP with the entire folder structure inside.

Hi! Example:

#include <GuiConstantsEx.au3>
#include <EditConstants.au3>
#include <WindowsConstants.au3>
#include <Zip32.au3>

Global $CurZipSize = 0

$hGUI = GUICreate("ZIP", 300, 160)

$edit = GUICtrlCreateEdit("", 10, 10, 280, 100, BitOR($WS_VSCROLL, $ES_AUTOVSCROLL, $ES_READONLY))

$progress = GUICtrlCreateProgress(10, 125, 280, 20)

GUISetState()

;=========# ZIP Demo #=======================================================
MsgBox(0, "ZIP", "Now we zipping a file", 0, $hGUI)

$ZipFile = FileSaveDialog("New Archive", "", "Archive files (*.zip)", 2, "", $hGUI)
If $ZipFile = "" Then Exit

$FileToZip = FileOpenDialog("Add file(s)", "", "All files (*.*)", 4, "", $hGUI)
If $FileToZip = "" Then Exit

$UnCompSize = DirGetSize($FileToZip)

_Zip_Init("_ZIPPrint", "_ZIPPassword", "_ZIPComment", "_ZIPProgress")
If @error Then
    MsgBox(16, "Error", "Zip32.dll did not initialize")
    Exit
EndIf

_Zip_SetOptions()
If @error Then
    MsgBox(16, "Error", "Options sets error")
    Exit
EndIf

;============= #Archives multiple files (just use a loop :))# ======================================
$aFiles = StringSplit($FileToZip, "|")

If UBound($aFiles) > 2 Then
    For $i = 2 To $aFiles[0]
        _ZIP_Archive($ZipFile, $aFiles[1] & "\" & $aFiles[$i])
    Next
Else
    _ZIP_Archive($ZipFile, $aFiles[1])
EndIf

;===================================================================================================

If @error Then
    MsgBox(16, "Error", "Archive creating error")
Else
    MsgBox(64, "Success", "Archive creating successful")
EndIf

GUICtrlSetData($progress, 0)
GUICtrlSetData($edit, "")
$CurZipSize = 0

;=========# UnZIP Demo #=======================================================
MsgBox(0, "ZIP", "Now we unzipping a file")

WinSetTitle($hGUI, "", "Unzip")

$ZipFile = FileOpenDialog("Select a zip archive", "", "Archive files (*.zip)")
If $ZipFile = "" Then Exit

;Global $CompSize = FileGetSize()

$OutDir = FileSelectFolder("Output Folder", "", 1)
If $OutDir = "" Then Exit

_UnZip_Init("_UnZIP_PrintFunc", "UnZIP_ReplaceFunc", "_UnZIP_PasswordFunc", "_UnZIP_SendAppMsgFunc", "_UnZIP_ServiceFunc")

_UnZIP_SetOptions()

_UnZIP_Unzip($ZipFile, $OutDir)
If @error Then
    MsgBox(16, "Error", "Archive unpacking error")
Else
    MsgBox(64, "Success", "Archive unpacking successful")
EndIf

;==========================# ZIP Dll-callback functions #======================================
Func _ZIPPrint($sFile, $sPos)
    ConsoleWrite("!> _ZIPPrint: " & $sFile & @LF)
EndFunc

Func _ZIPPassword($sPWD, $sX, $sS2, $sName)
    Local $iPass = InputBox("Archive encrypting set", "Enter the password", "", "", 300, 120)
    
    If $iPass = "" Then Return 1
    
    Local $PassBuff = DllStructCreate("char[256]", $sPWD)
    DllStructSetData($PassBuff, 1, $iPass)
EndFunc

Func _ZIPComment($sComment)
    Local $iComment = InputBox("Archive comment set", "Enter the comment", "", "", 300, 120)
    If $iComment = "" Then Return 1
    
    Local $CommentBuff = DllStructCreate("char[256]", $sComment)
    DllStructSetData($CommentBuff, 1, $iComment)
EndFunc

Func _ZIPProgress($sName, $sSize)
    ;Return 1 for abort the zip operation!
    $CurZipSize += Number($sSize)
    Local $iPercent = Round(($CurZipSize / $UnCompSize * 100))
    GUICtrlSetData($progress, $iPercent)
    GUICtrlSetData($edit, $sName & @CRLF, 1)
    
    ConsoleWrite("!> Name: " & $sName & @LF)
EndFunc

;==========================# UnZIP Dll-callback functions #========================================
Func _UnZIP_PrintFunc($sName, $sPos)
    ConsoleWrite("---> _UnZIP_PrintFunc: " & $sName & @LF)
EndFunc

Func UnZIP_ReplaceFunc($sReplace)
    If MsgBox(4 + 32, "Overwrite", "File " & $sReplace & " is exists." & @LF & "Do you want to overwrite all file?") = 6 Then
        Return $IDM_REPLACE_ALL
    Else
        Return $IDM_REPLACE_NONE
    EndIf
EndFunc

Func _UnZIP_PasswordFunc($sPWD, $sX, $sS2, $sName)
    ConsoleWrite("!> UnZIP_PasswordFunc: " & $sPWD & @LF)
    
    Local $iPass = InputBox("Password require", "Enter the password for decrypt", "", "", 300, 120)
    If $iPass = "" Then Return 1
    
    Local $PassBuff = DllStructCreate("char[256]", $sPWD)
    DllStructSetData($PassBuff, 1, $iPass)
EndFunc

Func _UnZIP_SendAppMsgFunc($sUcsize, $sCsize, $sCfactor, $sMo, $Dy, $sYr, $sHh, $sMm, $sC, $sFname, $sMeth, $sCRC, $fCrypt)
    ;ConsoleWrite("!> _UnZIP_SendAppMsgFunc: " & $sUcsize & @LF)
EndFunc

Func _UnZIP_ServiceFunc($sName, $sSize)
    ;Return 1 for abort the unzip!
    GUICtrlSetData($edit, $sName & @CRLF, 1)
    
    ConsoleWrite("!> Size: " & $sSize & @LF & _
                 "!> FileName" & $sName & @LF)
EndFunc

:)

Share this post


Link to post
Share on other sites
rasim

is it possible to print file that extract from the zip inside the status label?

my label is create from GUICtrlCreateLabel

if possible, how?

TQ

Yes, see example from attached archive in the first post and use GuiCtrlSetData() function :)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×