Solved

Zipping a file with delphi

Posted on 2004-04-01
9
791 Views
Last Modified: 2010-04-04
I need to shell winzip and zip MyFile.exe in the windows folder

i have tried this but it dosent work..

ShellExecute(handle, PCHAR('open'), PCHAR('c:\Program Files\Winzip\winzip32.exe'),'-a -r',Windir+'\NewFile.zip',Windir+'\MyFile.exe',SW_show);

or is there code to generate  a zip file whithout using winzip in your program?
0
Comment
Question by:KLOPEKS
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
9 Comments
 
LVL 2

Expert Comment

by:Ratje
ID: 10730982
U could use ZipForge from http://www.componentace.com/

Rat
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 10730999
I am using a ZipForge component for Delphi from
http://www.aidaim.com/
It is a free for personal use ZIP compression library.
example:
    with ZipForge do
    try
          FileName := edt_Zip_Source.Text; // 'D:\SFX.zip';
          OpenArchive(fmCreate); // Create a new archive file
          BaseDir := edt_Folder_Source.Text; // 'D:\SFX'; // Set path to folder with some text files to BaseDir
          AddFiles('*.*');   // Add all files and directories from 'C:\SOURCE_FOLDER' to the archive
          CloseArchive; // Close the archive
    except
       // Without success
    end;
0
 
LVL 6

Expert Comment

by:BAlexandrov
ID: 10731018
Here one good free component
http://groups.yahoo.com/group/nanozip/

there is the discussion group, you can download it from files section - there are examples too.

Bojidar Alexandrov
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Expert Comment

by:Ratje
ID: 10731059
Another good choice would be turboPower Abbrevia:
http://sourceforge.net/projects/tpabbrevia/

Rat
0
 
LVL 17

Accepted Solution

by:
mokule earned 125 total points
ID: 10731098
You call with 7 parameters whilst this function takes 6.
ShellExecute(handle,
                   PCHAR('open'),
                   PCHAR('c:\Program Files\Winzip\winzip32.exe'),
                   '-a -r', // here You should pass all parameters passed to Wnzip32 (see below)
                   Windir+'\NewFile.zip',  // default directory - not zip
                   Windir+'\MyFile.exe',   // delete this line
                   SW_show);


'-a -r '+ Windir+'\NewFile.zip' + ' ' + Windir+'\MyFile.exe',
if Your MyFile.exe is already in Windir Folder
0
 
LVL 1

Expert Comment

by:FeralCTO
ID: 10732786
esoftbg,

I looked at http://www.aidaim.com/ and was unable to find ZipForge.

0
 
LVL 12

Expert Comment

by:esoftbg
ID: 10736119
I have two accepted solutions with     http://www.aidaim.com/

01/26/2004     http://experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20862511.html

03/16/2004     http://experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20921124.html

I so sorry, I am surpised:
 http://www.aidaim.com/ is changed and there is not ZipForge anymore ????

I found version 2.51 or 2.52 at:
http://www.softandco.com/download/ZipForge/download11146.html

I am using version 2.02, I'll try a new one. I just downloaded it.

emil
0
 
LVL 12

Expert Comment

by:esoftbg
ID: 10736466
I recompiled an old application which used ZipForge 2.02 with a new version 2.52, and it works fine

  // example - ZIPPING a FOLDER 'D:\SFX'

  with ZipForge do
  begin
    if DirectoryExists('D:\SFX') then
    begin
      FileName := 'D:\SFX.zip';
      OpenArchive(fmCreate); // Create a new archive file D:\SFX.zip
      BaseDir := 'D:\SFX';      // Folder to be Zipped
      AddFiles('*.*');
      CloseArchive; // Close the archive
    end;
  end;

emil
0
 

Author Comment

by:KLOPEKS
ID: 10737387
thanks!
0

Featured Post

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question