How to extract zip archives in delphi?

hello experts.
please help me.
How can program automatically extract zip or rar archive into a folder?
please sugest a component or a code.
Who is Participating?
lomo74Connect With a Mentor Commented:
for zip format you can use TurboPower's Abbrevia components:

for rar, the only one I'm aware of handling this format (except rar itself) is 7-zip.
you can try this:
You can check "ZipTV Compression" component which supports many compression algorithms:

Also WinRAR Site has links for Delphi Components that can help you as well:

Download link:
Emmanuel PASQUIERFreelance Project ManagerCommented:
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( '*.*' );

Open in new window

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

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.
Emmanuel PASQUIERFreelance Project ManagerCommented:
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...
ThievingSixConnect With a Mentor Commented:
"And since WinRar is not free..."

There UnRAR.dll is AFAIK, I believe it does zip files as well.
Emmanuel PASQUIERFreelance Project ManagerCommented:
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
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:

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

> 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.
I am well aware of that, there are converters out there. I've seen it done, but it's pretty hackish.
Geert GOracle dbaCommented:
if it has a command line interface then you can use any compress/decompress tool by
building a delphi wrapper around it
with shellexecute
It does have a windows exe built with a cmd line interface as well.
> 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 :-)
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.
Emmanuel PASQUIERFreelance Project ManagerCommented:
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.
helyonprime96Author Commented:
thanks a lot
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.