Jump to content

Zip32


rasim
 Share

Recommended Posts

rasim,

Your example gives the same results.

Maybe we're talking about different things.

What I mean is that, INSIDE the zip, the folder structure remains like the source.

For example: If I zip the file c:\folder1\subfolder1\teste.txt

when opening up the file with WinZip, you will have to navigate the sames levels to get there (folder1 > subfolder1 > teste.txt)

I am looking for a way to prevent storing the entire path.

Thanks!

:)

Link to comment
Share on other sites

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

yes i have see the example, but my label are single line and yours is multiple line

i tried to make it single line but the print text just mess up. it print

the first extract file and second, third on the label without clearing it.

Posted Image

Func _UnZIP_ServiceFunc($sName, $sSize)

GUICtrlSetData($STATUS_LABEL_2, $sName)

EndFunc

how about extract with a progress bar is it possible?

Link to comment
Share on other sites

rasim,

Your example gives the same results.

Maybe we're talking about different things.

What I mean is that, INSIDE the zip, the folder structure remains like the source.

For example: If I zip the file c:\folder1\subfolder1\teste.txt

when opening up the file with WinZip, you will have to navigate the sames levels to get there (folder1 > subfolder1 > teste.txt)

I am looking for a way to prevent storing the entire path.

Thanks!

:)

See the _ZIP_SetOptions() function parameters in the Zip32.au3 UDF.

Example:

#include <Zip32.au3>

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

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

$FileToZip = FileOpenDialog("Select File...", "", "All files (*.*)")
If $FileToZip = "" Then Exit

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

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

_ZIP_Archive($ZipFile, $FileToZip)

If @error Then
    MsgBox(16, "Error", "Archive creating error")
Else
    MsgBox(64, "Success", "Archive creating 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!
    ConsoleWrite("!> Name: " & $sName & @LF)
EndFunc

$sJunkDir - [optional] 0 = (default) don`t junk directory names, 1 = junk directory names

Edited by rasim
Link to comment
Share on other sites

yes i have see the example, but my label are single line and yours is multiple line

i tried to make it single line but the print text just mess up. it print

the first extract file and second, third on the label without clearing it.

Posted Image

how about extract with a progress bar is it possible?

Example file contain many comprehensible examples.

Link to comment
Share on other sites

Ok, i am kind of new to autoit, but i really love the fact you are able to extract zip files, i just have a couple of questions as i can't get it to work on mine properly, and i was hoping you would be able to explain...i would be REALLY greatful!

Firstly when trying to use _UnZIP_Init

What values do i put for these, or do i leave them as they are?? Like i said i am very new to autoit

;------------------------V-------------------------V---------------------------V--------------------------------V-----------------------------V-----------------

_UnZIP_Init("$sUnZIP_PrintFunc", "$sUnZIP_ReplaceFunc", "$sUnZIP_PasswordFunc", "$sUnZIP_SendAppMsgFunc", "$sUnZIP_ServiceFunc")

And if i do leave them as they are shown above i get this error message:

C:\Program Files\AutoIt3\Include\Zip32.au3 (193) : ==> Badly formatted "Func" statement.:

$hCallBack_UnZIPPrint = DllCallbackRegister($sUnZIP_PrintFunc, "int", "str;long")

???????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????

Am i being really stupid? Don't worry you can tell me!

Instant Lockerz Invite - www.instantlockerzinvite.co.uk
Link to comment
Share on other sites

  • 2 weeks later...

@Catdaddy

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.

The DLL requests the password for every Directory (I suspect). So I had to change my script a little bit:

Global $iPass1="", $iPass2="" 

Func _ZIPPassword($sPWD, $sX, $sS2, $sName)
    If $iPass1 = "" Then
        Do
            $iPass1 = InputBox(@ScriptName, "Please enter Password:", "", "*", 300, 120)
            If $iPass1 = "" Then Return 1
            $iPass2 = InputBox(@ScriptName, "Please Re-Enter Password:", "", "*", 300, 120)
            If $iPass1 <> $iPass2 Then MsgBox(16,@ScriptName,"Passwords don't match. Please try again")
        Until ($iPass1 = $iPass2)
    EndIf
    
    Local $PassBuff = DllStructCreate("char[256]", $sPWD)
    DllStructSetData($PassBuff, 1, $iPass1)
EndFunc

BTW: Does anyone know what kind of encryption this version of InfoZip uses?

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

How to get total file size inside the zip file?

Not the zipped file size.

In the example the uncompressed size is computed in variable $UnCompSize.

For every File/Directory you compress you could sum up the size using FileGetSize/DirGetSize.

HTH

Thomas

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

water

Hi! Thank you for your interest this project.

he DLL requests the password for every Directory (I suspect)

No, the DLL call this function twice regardless of amount of the folders. First call - password request, second call - password confirm. :) Sorry for shortly example in the attached archive. >_<

In the example the uncompressed size is computed in variable $UnCompSize

Wrong, this variable contain the folder size, which we zipped in the example. Sorry guys, I have not found how to retrieve uncompressed size from a zip archieve :P But you may retrieve uncompressed size using archieve testing parameter and calculate size in the _UnZIP_ServiceFunc() function before unpacking.

Sorry for my english :idiot:

Link to comment
Share on other sites

Hi rasim,

You're right. I re-checked my script and found 3 calls to _ZIP_Archive. This gives 6 calls to _ZIPPassword. As I was zipping 6 Directories this led me to my wrong assumption.

You're right again. I didn't read the question properly.

BTW: Do you know what kind of encryption this version of InfoZip uses (AES, DES ...)?

Thanks for sharing this UDF!

Thomas

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

  • 2 months later...

hi

Unpacking files from the archive doesn`t work if within filepath, in archive, present square brackets.

for example file with such path:

"path1/path[2]/file.txt"

will not be unpacked

i findout it while i has using function _UnZIP_Unzip() for unpack each file individually.

Edited by shizoID
Link to comment
Share on other sites

hi

Unpacking files from the archive doesn`t work if within filepath, in archive, present square brackets.

for example file with such path:

"path1/path[2]/file.txt"

will not be unpacked

i findout it while i has using function _UnZIP_Unzip() for unpack each file individually.

Works fine for me. Can you make a small example to duplicate your problem? :)
Link to comment
Share on other sites

  • 12 years later...

Hmmm I'm having a problem providing a static password.  Not sure how to use the callback function or if there is an easier way:

Anyone have any idea of how to apply a password while zipping a folder:

#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 #=======================================================
$ZipFile = @ScriptDir & "\Result.zip"
$DirToZip = @ScriptDir & "\ZipThisFolder"
$UnCompSize = DirGetSize($DirToZip)
_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
_ZIP_Archive($ZipFile, $DirToZip)
If @error Then
    MsgBox(16, "Error", "Archive creating error")
Else
    MsgBox(64, "Success", "Archive creating successful")
EndIf

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

;==========================# 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!
    $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

Thanks for any tips

Link to comment
Share on other sites

  • Moderators

NassauSky,

Do you seriously expect anyone here now to know anything at all about a UDF from over 12 years ago?

M23

Public_Domain.png.2d871819fcb9957cf44f4514551a2935.png Any of my own code posted anywhere on the forum is available for use by others without any restriction of any kind

Open spoiler to see my UDFs:

Spoiler

ArrayMultiColSort ---- Sort arrays on multiple columns
ChooseFileFolder ---- Single and multiple selections from specified path treeview listing
Date_Time_Convert -- Easily convert date/time formats, including the language used
ExtMsgBox --------- A highly customisable replacement for MsgBox
GUIExtender -------- Extend and retract multiple sections within a GUI
GUIFrame ---------- Subdivide GUIs into many adjustable frames
GUIListViewEx ------- Insert, delete, move, drag, sort, edit and colour ListView items
GUITreeViewEx ------ Check/clear parent and child checkboxes in a TreeView
Marquee ----------- Scrolling tickertape GUIs
NoFocusLines ------- Remove the dotted focus lines from buttons, sliders, radios and checkboxes
Notify ------------- Small notifications on the edge of the display
Scrollbars ----------Automatically sized scrollbars with a single command
StringSize ---------- Automatically size controls to fit text
Toast -------------- Small GUIs which pop out of the notification area

 

Link to comment
Share on other sites

Sometimes I live in an unrealistic world 😕 My thought was that it's a very common process and there were quite a few references to this old UDF and figured a few people might still be using it.    I wound up doing it another way. Thanks for the smelling salt

Edited by NassauSky
Link to comment
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
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...