rasim Posted July 25, 2008 Share Posted July 25, 2008 (edited) 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. LicenseMain features:Create zip archiveExtract zip archiveSet archive commentRead archive commentEncrypt archiveDecrypt archiveCompression level 0-9Include\Exclude files by dateInclude\Exclude files by nameInclude\Exclude files by files numberInclude\Exclude system and hidden filesUpdate archiveFreshen archiveTest archiveAnd more... Download Zip32 UDFIncluded latest zip32.dll and unzip32.dll.Edit:Uploaded UDF on this site zip_udf.zip Edited July 25, 2008 by rasim netmaple, mLipok and yutijang 3 Link to comment Share on other sites More sharing options...
Andreik Posted July 25, 2008 Share Posted July 25, 2008 Nice work! Just tested and work fine. I like your scripts and your UDF. Thanks rasim! When the words fail... music speaks. Link to comment Share on other sites More sharing options...
Moderators SmOke_N Posted July 25, 2008 Moderators Share Posted July 25, 2008 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. LicenseMain features:Create zip archiveExtract zip archiveSet archive commentRead archive commentEncrypt archiveDecrypt archiveCompression level 0-9Include\Exclude files by dateInclude\Exclude files by nameInclude\Exclude files by files numberInclude\Exclude system and hidden filesUpdate archiveFreshen archiveTest archiveAnd more... Download Zip32 UDFIncluded 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. Link to comment Share on other sites More sharing options...
rasim Posted July 25, 2008 Author Share Posted July 25, 2008 AndreikSmOke_NJust 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 I upload UDF on this site, updated first post. Thanks for feedback guys! Link to comment Share on other sites More sharing options...
Catdaddy Posted August 26, 2008 Share Posted August 26, 2008 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. Link to comment Share on other sites More sharing options...
Garp99HasSpoken Posted August 27, 2008 Share Posted August 27, 2008 Nice work. Good addition to the site. Link to comment Share on other sites More sharing options...
rasim Posted August 27, 2008 Author Share Posted August 27, 2008 CatdaddyGarp99HasSpokenThanks for feedbacks guys Link to comment Share on other sites More sharing options...
jbnh Posted September 7, 2008 Share Posted September 7, 2008 (edited) 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 September 7, 2008 by jbnh Link to comment Share on other sites More sharing options...
rasim Posted September 7, 2008 Author Share Posted September 7, 2008 jbnhOh 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 Link to comment Share on other sites More sharing options...
jbnh Posted September 7, 2008 Share Posted September 7, 2008 my mistake too, didnt saw the error. Thanks dude. Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted September 7, 2008 Share Posted September 7, 2008 Hi Rasim,Did you ever think of combining your UDF with http://www.autoitscript.com/forum/index.ph...LLCall&st=0Emiel Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
rasim Posted September 8, 2008 Author Share Posted September 8, 2008 Hi Rasim,Did you ever think of combining your UDF with http://www.autoitscript.com/forum/index.ph...LLCall&st=0EmielYes, i thought about it. Link to comment Share on other sites More sharing options...
Emiel Wieldraaijer Posted September 8, 2008 Share Posted September 8, 2008 Yes, i thought about it.I haven't tried it yet.. do you think it would be possible ?Emiel Best regards,Emiel Wieldraaijer Link to comment Share on other sites More sharing options...
Vakari Posted September 8, 2008 Share Posted September 8, 2008 Excellent submission! I just thought I'd mention that your example worked flawlessly on Windows 2000 sp4. Link to comment Share on other sites More sharing options...
AskThatDude Posted September 18, 2008 Share Posted September 18, 2008 Is it possible to zip a file without including the current directory structure? Link to comment Share on other sites More sharing options...
rasim Posted September 19, 2008 Author Share Posted September 19, 2008 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. Link to comment Share on other sites More sharing options...
Undutchable Posted September 19, 2008 Share Posted September 19, 2008 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. Link to comment Share on other sites More sharing options...
FireNET Posted September 19, 2008 Share Posted September 19, 2008 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 Link to comment Share on other sites More sharing options...
rasim Posted September 19, 2008 Author Share Posted September 19, 2008 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: expandcollapse popup#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 Link to comment Share on other sites More sharing options...
rasim Posted September 19, 2008 Author Share Posted September 19, 2008 is it possible to print file that extract from the zip inside the status label?my label is create from GUICtrlCreateLabelif possible, how?TQYes, see example from attached archive in the first post and use GuiCtrlSetData() function Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now