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
Solved

How to extract zip archives in delphi?

Posted on 2011-03-09
16
2,106 Views
Last Modified: 2012-05-11
hello experts.
please help me.
How can program automatically extract zip or rar archive into a folder?
please sugest a component or a code.
Thanks.
0
Comment
Question by:helyonprime96
  • 5
  • 4
  • 3
  • +4
16 Comments
 
LVL 24

Expert Comment

by:jimyX
ID: 35082189
You can check "ZipTV Compression" component which supports many compression algorithms:
http://www.ziptv.com/index.html

Also WinRAR Site has links for Delphi Components that can help you as well:
http://www.rarlab.com/rar_add.htm

Download link:
http://www.rarlab.com/rar/RARComponent_12.zip
http://www.rarlab.com/rar/TDFUnRar.zip
0
 
LVL 8

Accepted Solution

by:
lomo74 earned 250 total points
ID: 35082218
for zip format you can use TurboPower's Abbrevia components:
http://sourceforge.net/projects/tpabbrevia/

for rar, the only one I'm aware of handling this format (except rar itself) is 7-zip.
you can try this:
http://www.rg-software.de/rg/index.php?option=com_content&view=article&id=29&Itemid=51
0
 
LVL 25

Expert Comment

by:epasquier
ID: 35082798
I remember using ZipTV as well, but since it is not free I decided against using it when I upgraded Delphi

So I tested and choose Abbrevia component set too. Very easy to use for a free set. Full of project samples for all the needs.
Here is how they extract all files in their Unzip demo project, can't be much simpler :

if OpenDialog1.Execute then begin
    with AbUnzipper1 do begin
      FileName := OpenDialog1.FileName;
      BaseDirectory := ExtractFilePath( FileName );
      ExtractFiles( '*.*' );
    end;
  end;

Open in new window

0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

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

 
LVL 2

Expert Comment

by:RezaSadigh
ID: 35083074
Hi my friend
Using third party component is good Idea, but you can use simply winrar.exe and CreateProcess
if you are interested say to I explain it more.
0
 
LVL 25

Expert Comment

by:epasquier
ID: 35083817
right, but then you would have to be sure that winrar is installed on each workstation where the application need to run.
And since WinRar is not free...
0
 
LVL 13

Assisted Solution

by:ThievingSix
ThievingSix earned 250 total points
ID: 35084894
"And since WinRar is not free..."

There UnRAR.dll is AFAIK, I believe it does zip files as well.
0
 
LVL 25

Expert Comment

by:epasquier
ID: 35085542
Interesting solution, if you can post the UnRar.dll interface to use it
Yet a native Delphi free component included in the app is better than a dll to distribute along with the exe, IMO
0
 
LVL 13

Expert Comment

by:ThievingSix
ID: 35086318
Oh, I wasn't proposing it as a solution. By all means the free component is the best solution. Just throwing it out there that there are other options.

And there are two delphi wrappers for the DLL found: http://www.rarlab.com/rar_add.htm

Not only that but the Unrar.dll source has a .lib file that you might be able to directly link into your project.

0
 
LVL 8

Expert Comment

by:lomo74
ID: 35086378
> Not only that but the Unrar.dll source has a .lib file that you might be able to directly link into your project.

No, you can't do that in Delphi.
Delphi can only link against object files in OMF format.
0
 
LVL 13

Expert Comment

by:ThievingSix
ID: 35086463
I am well aware of that, there are converters out there. I've seen it done, but it's pretty hackish.
0
 
LVL 37

Expert Comment

by:Geert Gruwez
ID: 35086629
if it has a command line interface then you can use any compress/decompress tool by
building a delphi wrapper around it
with shellexecute
0
 
LVL 13

Expert Comment

by:ThievingSix
ID: 35086690
It does have a windows exe built with a cmd line interface as well.
0
 
LVL 8

Expert Comment

by:lomo74
ID: 35086855
> I am well aware of that, there are converters out there.

Oh, sure? I didn't know about that. Please give some more details, I'm curious --

> I've seen it done, but it's pretty hackish.

The only way I know is
- extract single obj files from lib using lib.exe
- convert to OMF using coff2omf
- link
The drawback is that you must provide CRT functions like malloc, fopen, printf and so on...
Once, I tried something similar (I wanted to link openssl statically to a delphi app) but it was a huge task to satisfy all CRT dependencies, so i fell back to good old DLL :-)
0
 
LVL 13

Expert Comment

by:ThievingSix
ID: 35087041
That's basically the setup. Over the different projects I've just kept a unit for all the required functions the obj file wants, and add new ones where they come out. It's not the best option, but a option.
0
 
LVL 25

Expert Comment

by:epasquier
ID: 35092818
That is a fun thing to do, for sure. I know I have used coff2omf as well once but can't pinpoint on what purpose.
Yet, I think that this technique should be avoided when you have a dll, or when you can build a C-compiled dll around a .lib, because it can obviously be very time consuming.

Then , the only problem with .dll against static link is deployment issues. That can be leveled by integrating the dll as a resource and extract it in a temp folder before linking it when application starts. The user doesn't know the difference, and some Delphi components can help you do that in a few lines of code.
0
 

Author Closing Comment

by:helyonprime96
ID: 35107242
thanks a lot
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

837 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