Solved

How to extract zip archives in delphi?

Posted on 2011-03-09
16
2,004 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
 
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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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 36

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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

I know it’s not a new topic to discuss and it has lots of online contents already available over the net. But Then I thought it would be useful to this site’s visitors and can have online repository on vim most commonly used commands. This post h…
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
In this fourth video of the Xpdf series, we discuss and demonstrate the PDFinfo utility, which retrieves the contents of a PDF's Info Dictionary, as well as some other information, including the page count. We show how to isolate the page count in a…

759 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now