Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Unzip files?? 1

Status
Not open for further replies.

Rogy

Programmer
Nov 20, 2002
43
SI
I am trying to unzip files.
I used the API function called ShellExecute() by Mike Lewis.

This function works fine, with this sytax:

do OpenFile with 0,"open","c:\temp\dtec-l.zip","","",1

But the problem is, that WinZip is opened first, and
I have to unzip this file manually.
I want immediately extraction of the file!!

How can I do that?!
Is there another way?

Rogy
 
Rogy

If you right-mouse on a zipped file, you can see the options available as to what to do with the file, so instead of using "open " which opens the zip file as you can see, try using "Extract to...".


Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 

I tried with right click...
I got:
"Open with WinZip"
"Print"
"Winzip" ->(Here is submenu) -> Extract to...
Extract to here
Extract to folder x

This is what I tried:
do OpenFile with 0,"Extract to","c:\temp\dtec-l.zip","","",1
do OpenFile with 0,"Extract to here","c:\temp\dtec-l.zip","","",1
do OpenFile with 0,"Extract","c:\temp\dtec-l.zip","","",1
do OpenFile with 0,"Extract to...","c:\temp\dtec-l.zip","","",1

...but nothing of the above works

Any Idea?

Rogy

 
Rogy

I know, and I'm sorry for suggesting something without testing it myself. I would suggest you rely on the command line support that winzip offers.
Mike Gagnon

If you want to get the best response to a question, please check out FAQ184-2483 first.
 
Rogy,

The only thing you can ShellExecute() with WinZip is to open the file. There is no Unzip or similar parameter that you can pass to ShellExecute().

I think Mike G has the best advice: check out the command-line parameters for WinZip. For that matter, if you've got PKZip, you can RUN that directly, without Winzip.

Mike Lewis
Edinburgh, Scotland
 
Actually you can use the ShellExecute to extract your files, just not quite the way you have been:

Code:
FUNCTION UnZip
	PARAMETERS m.FILENAME,m.DESTDIR
	LOCAL LNRETVAL, LCOPERATION
	LCOPERATION = "Open"
	DECLARE INTEGER ShellExecute IN SHELL32.DLL ;
		INTEGER handle,;
		STRING @sFile,;
		STRING @lp,;
		STRING @DIR,;
		STRING @dir1,;
		INTEGER ncmd
	LNRETVAL = SHELLEXECUTE(0, LCOPERATION, "Winzip",;
        "-min -e "+m.FILENAME+" "+m.DESTDIR, "", 1)
	RETURN(.F.)

Then use the following to complete the extraction:

Code:
Unzip("C:\MYZIPFILE.ZIP","C:\MYDESTDIR\")

As with all things there are snags, you don't know when its finished for example - but that could be tested for...

HTH Regards

Griff
Keep [Smile]ing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top