Jump to content

Recommended Posts

Well I don't know much about this in AutoIt3 but this could help you if you'r into DLLCall dll stuff... :)

;Register the ZIP32.DLL function ZipInit(). This initializes the ZIP32.DLL

ZIPPRINT = '32u, void, 32u'

ZIPCOMMENT = 'void, void'

ZIPPASSWORD = '32, void, 32, void, void'

ZIPFUNCS = "func ZIPPRINT, func ZIPCOMMENT, func ZIPPASSWORD, void"

$zpi = DLLCall("ZpInit", "32, struct ZIPFUNCS", "zip32") // not correct

;Register the ZIP32.DLL function ZpSetOptions(). This sets some options.

ZIPOPTS = "void, str *, void, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 32u, 8u"

$zps = DLLCall("ZpSetOptions", "32u, struct ZIPOPTS", "zip32") // Not correct

;ZIPNAMES struct must have a "str *" field for each filename you wish to add to the ZIP file. Here we declare it as having 16 fields, which means we're limited to 16 files in the zip. You can expand this if you need to.

ZIPNAMES = "str *, str *, str *, str *, str *, str *, str *, str *, str *, str *, str *, str *, str *, str *, str *, str *"

;Register the ZIP32.DLL function ZpArchive(). This zips the files

$zpa = DLLCall("ZpArchive", "32, 32u, str, struct ZIPNAMES", "zip32") // not correct

;Initialize a ZIPFUNCS struct

ZipFuncs.1 = 'ZipPrint'

ZipFuncs.2 = 'ZipComment'

ZipFuncs.3 = 'ZipPassword'

ZipFuncs.4 = 0

;Initialize the ZIP32.DLL

IF ZpInit(ZipFuncs) = 0 THEN

ConsoleWrite("ZpInit failure!" & @CRLF)

RETURN

ENDIF

;Zero out all the numeric fields of the ZIPOPTS struct

FOR $i = 1 TO 32

ZipOpts.$i = 0

NEXT

;Set the directory to the same one that RXFILE set

ZipOpts.2 = 'The files directory'

#CS

* Some of the above fields may be set to 1 (instead of 0)

* for certain options, as so:

*

* ZipOpts.6 (Encrypt files)

* ZipOpts.7 (Include system and hidden files)

* ZipOpts.8 (Include the drive label)

* ZipOpts.9 (Exclude extra attributes)

* ZipOpts.10 (Do not add directory entries)

* ZipOpts.13 (Report oddities in the file)

* ZipOpts.14 (Quiet operation)

* ZipOpts.15 (Translate '0D0A'X to '0A'X, ie, CR/LF to LF)

* ZipOpts.16 (Translate '0A'X to '0D0A'X, ie, LF to CR/LF)

* ZipOpts.17 (Junk directory names)

* ZipOpts.18 (Allow appending to a zip file)

* ZipOpts.19 (Make entries using DOS names, ie k for Katz)

* ZipOpts.20 (Delete files added or updated in zip file)

* ZipOpts.21 (Delete files from zip file)

* ZipOpts.22 (Update zip file--overwrite only if newer)

* ZipOpts.23 (Freshen zip file--overwrite only)

* ZipOpts.24 (Junk SFX prefix)

* ZipOpts.25 (Set zip file time to time of latest file in it)

* ZipOpts.26 (Put comment in zip file. Our ZipComment subroutine would need to return the comment text)

* ZipOpts.27 (Update archive offsets for SFX files)

* ZipOpts.28 (Use privileges)

*

* ==============================

*

* ZipOpts.30 can be set to 1 if you want to recurse into subdirectories (-r option,

* or 2 if the -R option).

*

* ZipOpts.31 can be set to 1 if you want to repair the zip file (-F option,

* or 2 if the -FF option).

*

* ZipOpts.32 is the compression level 0 to 9 (where 0 is the default level, and 9 is maximum).

#CE

;Set the options

ZpSetOptions(ZipOpts)

;We have a limit of 16 names due to our ZIPNAMES struct definition

IF ZipNames.0 > 16 THEN ZipNames.0 = 16

;The file names were already set into ZipNames.1 to ZipNames.16

#CS

* Zip them into a ZIP file named "test.zip" in the TEMP dir, but first

* delete any such file. Otherwise we would be adding these to that

* existing zip archive.

#CE

ZipName = Path || "test.zip"

Delete the file(ZipName)

ZipName = 'c:\Test.zip'

IF ZpArchive(ZipNames.0, ZipName, ZipNames) <> 0 THEN ConsoleWrite("ZpArchive error!" & @CRLF)

This is an example I got in memory from another language, quickly translated and non function but could give you a clue to what to do - I would like to see a working example if this succeed for you...

Kåre :D

Link to post
Share on other sites

No I know 'no structures in autoit3' but it could made functional anyway as direct call if one is on homeground to library calls as this is a nice zip32 example from another language and I got a semilare example to use UnZip32 just as well if one get this library to work with autoit - I like to see an example anyway but do not have the spirit me self...

Kåre

Edited by kjactive
Link to post
Share on other sites
  • 2 months later...

hmmm, speaking of zipping files, is there any scripts made that will zip files and unzip them automatically?

it would also be nice to prompt the user to download winzip if its not installed, and download it if they click yes.

i would work on it myself, but im not sure if one already exists.

Valik Note Added 19 October 2006 - 08:38 AMAdded to warn level I just plain don't like you.

Link to post
Share on other sites
  • 1 month later...

I'd also like to do this but using the Zip dll file from the 7-Zip package. Anyone know how I could do it?

<{POST_SNAPBACK}>

As the web site, the program and it's DLLs are open source, and all the source and documentation is freely available.
Link to post
Share on other sites
  • 2 years later...

Well, im trying to work with zlib also, but the callDll function returns error code 3 (no function found).

Here is the code :

$logsList=_FileListToArray($GQM,"*.log")

If @error = 4 Then

FileWriteLine($appLog,$prefix & "No files found in the desingnated folder")

Else

FileWriteLine($appLog,$prefix & "Found " & _ArraySize($logsList)-1 & " log files")

$zipPath = IniRead(@ScriptDir & "\gqm.ini","GQM","zipPath", "NotFound")

$zipFileName = IniRead(@ScriptDir & "\gqm.ini","GQM","zipFileName", "NotFound") & "_" & @MDAY()&@MON&@YEAR&"_"&@HOUR&@MIN&@SEC&".zip"

DllCall("zlib.dll","str","CreateZipFile","str",$GQM,"hwnd",$logsList,"str",$zipFileName)

ConsoleWrite( "Return code : " & @error & @CRLF)

EndIf

Any idea?

Link to post
Share on other sites

Maybe the bit I bolded...

$logsList= _FileListToArray($GQM,"*.log")

If @error = 4 Then
FileWriteLine($appLog,$prefix & "No files found in the desingnated folder")
Else
FileWriteLine($appLog,$prefix & "Found " & _ArraySize($logsList)-1 & " log files")
$zipPath = IniRead(@ScriptDir & "\gqm.ini","GQM","zipPath", "NotFound")
$zipFileName = IniRead(@ScriptDir & "\gqm.ini","GQM","zipFileName", "NotFound") & "_" & @MDAY[b]()[/b]&@MON&@YEAR&"_"&@HOUR&@MIN&@SEC&".zip"

DllCall("zlib.dll","str","CreateZipFile","str",$GQM,"hwnd",$logsList,"str",$zipFileName)
ConsoleWrite( "Return code : " & @error & @CRLF)

() should not be there?

And way to bring up the past... :)

Link to post
Share on other sites
  • 3 years later...

Why not use 7-zip32.dll it has lots of func's and has the ability to work with zip files. click to view the post about the dll.

Look at the dates the next time you post :graduated:
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
  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...