Question:
How can I transparently zip a list of files (all in the same folder).
I assume dllcall would be most useful, but I can't find anything useful.
I am not sure where to start.

how? transparent zip with ahk. dllcall?
Started by
BETLOG
, Dec 24 2006 02:13 AM
31 replies to this topic
#1
-
Posted 24 December 2006 - 02:13 AM

i would say to use a command line zip program. i think winrar has such capabilities (you might have to pay though...)
#2
-
Posted 24 December 2006 - 04:53 AM


"Power can be given overnight, but responsibility must be taught. Long years go into its making."
For free zipping use Info-ZIP (<!-- m -->http://www.info-zip.org/<!-- m -->)
#3
-
Posted 24 December 2006 - 07:59 AM

...yes I think command line or a dll that each zip program MAY provide is the only solution......command line zip program.
...no!...screw WinRAR...screw paying...i think winrar has such capabilities (you might have to pay though...)
[*:1aqmt7gq]7-Zip
[*:1aqmt7gq]IZArc
[*:1aqmt7gq]TUGZip
[*:1aqmt7gq]ZipGenius
[*:1aqmt7gq]Comparison of file archivers - Wikipedia...why do people keep insisting on paying for WinRAR?...when free zipping exists!...even the freeware AutoHotkey is shipped in self-extracting WinRAR .exe's...why???
#4
-
Posted 24 December 2006 - 08:19 AM

Useful forum links: New content since: Last visit â– Past week â– Past 2 weeks (links will show YOUR posts, not mine)
OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...
Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".
I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?
OMFG, the AutoHotkey forum is IP.board now (yuck!)...I may not be able to continue coming here (& I love AutoHotkey)...I liked phpBB, but not this...ugh...
Note...
I may not reply to any topics (specifically ones I was previously involved in), mostly cuz I can't find the ones I replied to, to continue helping, but also just cuz I can't stand the new forum...phpBB was soo perfect. This is 100% the opposite of "perfect".
I also semi-plan to start my own, phpBB-based AutoHotkey forum (or take over the old one, if he'll let me)
PM me if you're interested in a new phpBB-based forum (I need to know if anyone would use it)How (or why) did they create the Neil Armstrong memorial site (neilarmstronginfo.com) BEFORE he died?
I think you may all misunderstand:
I know about the utilities available, I do not want to have to use them for this.
I know XP has inbuilt zip capabilities, so i want to know how to use dllcall to invoke it.
I know about the utilities available, I do not want to have to use them for this.
I know XP has inbuilt zip capabilities, so i want to know how to use dllcall to invoke it.
#5
-
Posted 24 December 2006 - 09:16 AM

I searched already, ended in using TUGZip scripting capability, and now using 7-Zip command line.
XP has unzipping capability, but AFAIK, no zipping functionnality.
XP has unzipping capability, but AFAIK, no zipping functionnality.
#6
-
Posted 24 December 2006 - 10:21 AM


So then how does this work?
right click on a file/folder
select 'send to'
select 'Compressed (zipped) folder'
Xp has zip/unzip capabilities out of the box afaik.
right click on a file/folder
select 'send to'
select 'Compressed (zipped) folder'
Xp has zip/unzip capabilities out of the box afaik.
#7
-
Posted 24 December 2006 - 10:28 AM

@BETLOG
I found some code to get you started.
Background:
Ever needed to compress Zip files and needed a better Zip than what comes with many of the free compression libraries out there? I.e. you needed to compress folders and subfolders as well as files. Windows Zipping can compress more than just individual files. All you need is a way to programmatically get Windows to silently compress these Zip files. Of course you could spend $300 on one of the commercial Zip components, but it's hard to beat free if all you need is to compress folder hierarchies.
Using the code
The following code shows how to use the Windows Shell API to compress a Zip file. First you create an empty Zip file. To do this create a properly constructed byte array and then save that array as a file with a '.zip' extension. How did I know what bytes to put into the array? Well I just used Windows to create a Zip file with a single file compressed inside. Then I opened the Zip with Windows and deleted the compressed file. That left me with an empty Zip. Next I opened the empty Zip file in a hex editor (Visual Studio) and looked at the hex byte values and converted them to decimal with Windows Calc and copied those decimal values into my byte array code. The source folder points to a folder you want to compress. The destination folder points to the empty Zip file you just created. This code as is will compress the Zip file, however it will also show the Copy Progress window. To make this code work, you will also need to set a reference to a COM library. In the References window, go to the COM tab and select the library labeled 'Microsoft Shell Controls and Automation'.
//Ziping a file using the Windows Shell API
//creates another thread where the zipping is executed.
//This means that it is possible that this console app
//would end before the zipping thread
//starts to execute which would cause the zip to never
//occur and you will end up with just
//an empty zip file. So wait a second and give
//the zipping thread time to get started
System.Threading.Thread.Sleep(1000);
The sample solution included with this article shows how to put this code into a console application and then launch this console app to compress the Zip without showing the Copy Progress window.
The code below shows a button click event handler that contains the code used to launch the console application so that there is no UI during the compress:
Points of Interest
It's free!
You can use Windows to create the Zip file instead of an expensive Zip library to work with folder hierarchies.
Works with or without showing the Copy Progress window.
Uses the Windows Shell API which has a lot of of interesting Windows integration possibilities
Regards
Dave.
I found some code to get you started.
Background:
Ever needed to compress Zip files and needed a better Zip than what comes with many of the free compression libraries out there? I.e. you needed to compress folders and subfolders as well as files. Windows Zipping can compress more than just individual files. All you need is a way to programmatically get Windows to silently compress these Zip files. Of course you could spend $300 on one of the commercial Zip components, but it's hard to beat free if all you need is to compress folder hierarchies.
Using the code
The following code shows how to use the Windows Shell API to compress a Zip file. First you create an empty Zip file. To do this create a properly constructed byte array and then save that array as a file with a '.zip' extension. How did I know what bytes to put into the array? Well I just used Windows to create a Zip file with a single file compressed inside. Then I opened the Zip with Windows and deleted the compressed file. That left me with an empty Zip. Next I opened the empty Zip file in a hex editor (Visual Studio) and looked at the hex byte values and converted them to decimal with Windows Calc and copied those decimal values into my byte array code. The source folder points to a folder you want to compress. The destination folder points to the empty Zip file you just created. This code as is will compress the Zip file, however it will also show the Copy Progress window. To make this code work, you will also need to set a reference to a COM library. In the References window, go to the COM tab and select the library labeled 'Microsoft Shell Controls and Automation'.
//Create an empty zip file byte[] emptyzip = new byte[]{80,75,5,6,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0}; FileStream fs = File.Create(args[1]); fs.Write(emptyzip, 0, emptyzip.Length); fs.Flush(); fs.Close(); fs = null; //Copy a folder and its contents into the newly created zip file Shell32.ShellClass sc = new Shell32.ShellClass(); Shell32.Folder SrcFlder = sc.NameSpace(args[0]); Shell32.Folder DestFlder = sc.NameSpace(args[1]); Shell32.FolderItems items = SrcFlder.Items(); DestFlder.CopyHere(items, 20);
//Ziping a file using the Windows Shell API
//creates another thread where the zipping is executed.
//This means that it is possible that this console app
//would end before the zipping thread
//starts to execute which would cause the zip to never
//occur and you will end up with just
//an empty zip file. So wait a second and give
//the zipping thread time to get started
System.Threading.Thread.Sleep(1000);
The sample solution included with this article shows how to put this code into a console application and then launch this console app to compress the Zip without showing the Copy Progress window.
The code below shows a button click event handler that contains the code used to launch the console application so that there is no UI during the compress:
private void btnUnzip_Click(object sender, System.EventArgs e) { //Test to see if the user entered a zip file name if(txtZipFileName.Text.Trim() == "") { MessageBox.Show("You must enter what" + " you want the name of the zip file to be"); //Change the background color to cue the user to what needs fixed txtZipFileName.BackColor = Color.Yellow; return; } else { //Reset the background color txtZipFileName.BackColor = Color.White; } //Launch the zip.exe console app to do the actual zipping System.Diagnostics.ProcessStartInfo i = new System.Diagnostics.ProcessStartInfo( AppDomain.CurrentDomain.BaseDirectory + "zip.exe"); i.CreateNoWindow = true; string args = ""; if(txtSource.Text.IndexOf(" ") != -1) { //we got a space in the path so wrap it in double qoutes args += "\"" + txtSource.Text + "\""; } else { args += txtSource.Text; } string dest = txtDestination.Text; if(dest.EndsWith(@"\") == false) { dest += @"\"; } //Make sure the zip file name ends with a zip extension if(txtZipFileName.Text.ToUpper().EndsWith(".ZIP") == false) { txtZipFileName.Text += ".zip"; } dest += txtZipFileName.Text; if(dest.IndexOf(" ") != -1) { //we got a space in the path so wrap it in double qoutes args += " " + "\"" + dest + "\""; } else { args += " " + dest; } i.Arguments = args; //Mark the process window as hidden so //that the progress copy window doesn't show i.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; System.Diagnostics.Process p = System.Diagnostics.Process.Start(i); p.WaitForExit(); MessageBox.Show("Complete"); }
Points of Interest
It's free!
You can use Windows to create the Zip file instead of an expensive Zip library to work with folder hierarchies.
Works with or without showing the Copy Progress window.
Uses the Windows Shell API which has a lot of of interesting Windows integration possibilities
Regards
Dave.
#8
-
Posted 24 December 2006 - 10:52 AM

Simple ideas lie within reach, only of complex minds
Unfortunately I am not a programmer, so while that looks like it contains what I need to know, it is also complex enough that I have already decided that the script I have spent that last 20 or so hours working on will now go on hold. At least until I find an easier way to do this, or resign myself to the script having less/different functionality.
...it also references zip.exe and only one of the dll's I expected to see, which makes me suspect it's not what I was after.
Also, what is the source of that text/code you pasted?
[edit] answer: <!-- m -->http://www.codeproje... ... lapics.asp<!-- m -->
...it also references zip.exe and only one of the dll's I expected to see, which makes me suspect it's not what I was after.
Also, what is the source of that text/code you pasted?
[edit] answer: <!-- m -->http://www.codeproje... ... lapics.asp<!-- m -->
#9
-
Posted 24 December 2006 - 11:41 AM

I feared you will answer something like that... Actually, I deactivate Zip support in XP as soon as I can, so I have no experience in the field...So then how does this work?
right click on a file/folder
select 'send to'
select 'Compressed (zipped) folder'
Xp has zip/unzip capabilities out of the box afaik.
Let say I didn't found relevant WinAPI, so perhaps the only entry point might be the shell...
Dippy46's extract is interesting (you should give the URL of your findings, BTW), but alas it shows Com code, not supported by AHK. Currently, you have to create a VBS (or JScript, etc.) script and run it to make it run...
#10
-
Posted 24 December 2006 - 02:35 PM


I tried to find some 'declarations' (if thats the right term) for shell32.dll, but came up with nothing useful.
I am surprised that nobody has tried to do this yet.
I did discover *some* things, but not much:
[quote]http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=692917&SiteID=1
Hi, I'm looking at creating a small app that needs to compress files and folders. Obviously, i'll need this to use Windows' built-in zip support (because otherwise my app would have to use 3rd party software that I'd need to distribute along with it)
I know that the command rundll32.exe zipfldr.dll,RouteTheCall %filename% opens a zip file in explorer, but I need the command to create a zip file.
Keywords:: Rundll32.exe, Zipfldr.dll, Dunzip32.dll, Dzip32.dll
<!-- m -->http://groups.google... ... 10ec912262<!-- m -->
rundll32.exe zipfldr.dll,RouteTheCall %L
The Compressed Folders feature uses the following system files:
Dunzip32.dll: Responsible for decompressing files stored in a compressed
folder or file when they are copied, extracted, or executed.
Dzip32.dll: Responsible for compressing files when they are put into a
compressed folder or file.
Zipfldr.dll: Contains the shell extensions for Compressed Folders.
Compressed Folder.ZFSendToTarget: Adds the Compressed Folder option to the
Send To menu. A shortcut is placed in the Send To directory that points to
Zipfldr.dll.
Settings for Compressed Folders in the Registry
The following registry key contains the settings for Compressed Folders:
HKEY_CLASSES_ROOT\CompressedFolder
[/quote][/quote]
I am surprised that nobody has tried to do this yet.
I did discover *some* things, but not much:
[quote]http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=692917&SiteID=1
Hi, I'm looking at creating a small app that needs to compress files and folders. Obviously, i'll need this to use Windows' built-in zip support (because otherwise my app would have to use 3rd party software that I'd need to distribute along with it)
I know that the command rundll32.exe zipfldr.dll,RouteTheCall %filename% opens a zip file in explorer, but I need the command to create a zip file.
Keywords:: Rundll32.exe, Zipfldr.dll, Dunzip32.dll, Dzip32.dll
<!-- m -->http://groups.google... ... 10ec912262<!-- m -->
rundll32.exe zipfldr.dll,RouteTheCall %L
The Compressed Folders feature uses the following system files:
Dunzip32.dll: Responsible for decompressing files stored in a compressed
folder or file when they are copied, extracted, or executed.
Dzip32.dll: Responsible for compressing files when they are put into a
compressed folder or file.
Zipfldr.dll: Contains the shell extensions for Compressed Folders.
Compressed Folder.ZFSendToTarget: Adds the Compressed Folder option to the
Send To menu. A shortcut is placed in the Send To directory that points to
Zipfldr.dll.
Settings for Compressed Folders in the Registry
The following registry key contains the settings for Compressed Folders:
HKEY_CLASSES_ROOT\CompressedFolder
[/quote][/quote]
#11
-
Posted 24 December 2006 - 08:15 PM

@BETLOG
Ok, good research but, the question remains, where's Dunzip32.dll and Dzip32.dll hiding ?
Dave.
Ok, good research but, the question remains, where's Dunzip32.dll and Dzip32.dll hiding ?
Dave.
#12
-
Posted 25 December 2006 - 07:27 PM

Simple ideas lie within reach, only of complex minds
I'm suspecting it's been moved to functions within zipfldr.dll .... but that's my problem; I have almost nothing to move forward with.
#13
-
Posted 26 December 2006 - 02:26 AM

You should be able to dllcall it.
That is, of course, after you figure out which call to use. I seem to remember some programs someone linked to on the foruw that allowed you to see the calls within a dll. You could search the forums or google it.
That is, of course, after you figure out which call to use. I seem to remember some programs someone linked to on the foruw that allowed you to see the calls within a dll. You could search the forums or google it.
#14
-
Posted 26 December 2006 - 02:30 AM


"Power can be given overnight, but responsibility must be taught. Long years go into its making."
I'd be interested in that.
I just found this: but it's not exactly zipping the files/folders into a new file (which is what i want), it's just compressing the files/folders as they are, and not very much at that.
<!-- m -->http://www.computerh...com/compact.htm<!-- m -->
I just found this: but it's not exactly zipping the files/folders into a new file (which is what i want), it's just compressing the files/folders as they are, and not very much at that.
<!-- m -->http://www.computerh...com/compact.htm<!-- m -->
#15
-
Posted 26 December 2006 - 03:30 AM
