Re: How to specify the folder that i wish to zip??

Posted by webmaster Guido on December 27, 2001

In Reply to: How to specify the folder that i wish to zip?? posted by joyce on December 27, 2001:

: i tried using
: ShellExecute(Handle, 'Open', 'WinZip32.exe', '-a c:\', nil, SW_NORMAL);

: but i am not able to specify the folder that i wish to zip!


The command format for winzip32 is:

winzip32 [-min] Action [options] Filename[.zip] Files

-min specifies that WinZip should run minimized.

-a for add;
-f for freshen;
-u for update;
-m for move.

-r include subfolders;
-p store folder information for all files added;
-ex, -en, -ef, -es, and -e0 determine the compression method: eXtra, Normal, Fast, Super fast, and no compression.
-hs includes hidden and system files.
-sPassword to specify a case-sensitive password. The password can be enclosed in quotes, for example, -s"Secret Password".

Filename or is the name of the zipfile that you create. If you don't specify an extension, it will become .zip

Files is a list of one or more files, or the @ character followed by the filename containing a list of files to add, one filename per line. Wildcards (such as *.*) are allowed.

Examples of commands:

Zip the file data.dat to a file, with data.dat in c:\source and in c:\dest

c:\program files\winzip\winzip32 -a c:\dest\data c:\source\data.dat 

Zip all the files of folder c:\source into a zipfile called and don't show the Winzip window:

c:\program files\winzip\winzip32 -min -a c:\dest\all c:\source\*.* 

With ShellExecute this becomes (I tested it and it works fine):

ShellExecute(Handle, 'Open', 'c:\program files\winzip\winzip32.exe',
 '-min -a c:\dest\all c:\source\*.*', nil, SW_NORMAL); 

Or, if you want to make a procedure that you call like this:
ZipIt('c:\source\*.*', 'c:\dest\');

then the procedure would be:

procedure TForm1.ZipIt(Source, Destination: string);
  Zipper = 'c:\program files\winzip\winzip32.exe';
  Params: string;
  Params := '-min -a ' + Destination + ' ' + Source;
  ShellExecute(Handle, 'Open', PChar(Zipper), PChar(Params), nil, SW_NORMAL);