Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Visual Basic > VB 6 Visual Basic 6 > Pro VB 6
|
Pro VB 6 For advanced Visual Basic coders working in version 6 (not .NET). Beginning-level questions will be redirected to other forums, including Beginning VB 6.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro VB 6 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 1st, 2003, 09:37 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default File Compression: Automation

My goal is to automate the functionality of WinZip from within a Visual Basic 6.0 application.

In my efforts I have created a dll as a wrapper to the WinZip utility. The initial results
appeared to work well. The program uses the WinZip Command Line Add-On, a beta release, and WinZip 9.0 a beta release also. Initially I had used the Windows Scripting Host Object (WSHom) to make the calls to the command line. But, we experienced problems when the file name exceeded 15 characters. Not a problem for new releases but this application has to work with legacy files as well. When investigating a resolution I now understand the Windows Scripting Host cannot handle long file name. Also, the API ShortPathName( ) only returns a value if a file already exist. I read that if you enclose the command in double quotation marks the WSHom will accept it. But I was unable to get that to execute anything?

Since then I have changed the application to use the Shell( ) function. It appears to be working only about half of the time with various errors. WinZip itself never returns any errors? These are the two problems I have been encountering.

1. WinZip will execute but no file will be made. I have noticed this when executed within a For loop. To try and resolve this issue I have added a function to check for the existence of the file prior to executing the next loop. This has added considerable time to our application but seemed to resolve the situation minus the following problem.

2. WinZip will create the zipped file however the original file is not in the zipped file and
the file size is 0 kb.

Perhaps I have misunderstood the purpose of the utility.

Here are some samples of the command line arguments being executed:

' The following code is only for reference purposes
' The actual code is dynamic but this should enable you
' to better understand what is happening in the program

Dim lError as Long
Dim dX as Double
Dim strArg as String
Dim ws As WshShell ' Reference wshom.ocz

' Successful command using WSHom.ocx
strARG = "COMMAND.COM /C C:\PROGRA~1\WinZip\wzzip.exe -ee -o -jhrs" & Chr(34) & "C:\Temp\Vault\5108889510889.dwg.zip" & Chr(34) & "C:\Larry\COPYOF~1\5108889510889.dwg"

lError = ws.Run(strArg, vbMinimizedNoFocus, True)

' Failed command using WSHom.ocx
strARG = "COMMAND.COM /C C:\PROGRA~1\WinZip\wzzip.exe -ee -o -jhrs" & Chr(34) & "C:\Temp\Vault\51088895108890.dwg.zip" & Chr(34) & "C:\Larry\COPYOF~1\51088895108890.dwg"

lError = ws.Run(strArg, vbMinimizedNoFocus, True)

' Command executed using the shell function
strArg = "C:\PROGRA~1\WinZip\wzzip.exe -ee -o -jhrs" & Chr(34) &
"C:\Temp\Vault\51088895108890.dwg.zip" & Chr(34) & C:\Larry\COPYOF~1\51088895108890.dwg"

dx = Shell(strArg, vbMinimizedNoFocus)

Please offer your advise. At this point I am looking to either resolve the issue with
the Windows Scripting Host Object. But I am more inclined to look at an alternative to
WinZip.

Thanks in advance for your help,

Larry Asher


Larry Asher
__________________
Larry Asher
 
Old July 1st, 2003, 09:55 AM
Registered User
 
Join Date: Jun 2003
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via ICQ to Kilian
Default

Why do you not cut the long filename and replace it with a short one ?

and you can not recive a error message from winzip ... (maybe this will never happen...) the other way is you use a diffrent compression tool like winrar ... !

cheers Kilian
 
Old July 1st, 2003, 10:02 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The first part of your response is one of the basis pf my question. How do you generate a short file name? As I mention the API ShortPathName() only returns a value if the file exist. In the case when compressing a file, creating a new file, a zero length string is returned. The other restraint as mentioned is the application has to work with legacy files. Paths seem to be an issue also if they include spaces.

In regards to Winrar I would like to see more information. Have you used Winrar for file compression? Or more specifically have you automated Winrar successfully?

Thanks for your reply,


Larry Asher
 
Old July 1st, 2003, 10:04 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there..

there's is an ocx from winzip that do all the work.. why try to mess with the command line??

Gonzalo Bianchi
 
Old July 1st, 2003, 10:25 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

That would be great but I have been corresponding with WinZip in regards to this problem and they never mentioned an OCX. Also, I just went to there website after reading your reply and I cannot find any mention of an OCX? If you have any information could you share that with me?

Thanks,

Larry Asher
 
Old July 1st, 2003, 10:36 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

try this link
[link]http://www.xceedsoft.com/[/link]

we use that component ( a four year old version) and still work...

Gonzalo Bianchi
 
Old July 1st, 2003, 11:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 128
Thanks: 0
Thanked 0 Times in 0 Posts
Default

That look really good to me. I am implementing the trial version now.

Thanks,

Larry Asher
 
Old November 4th, 2008, 06:22 AM
Authorized User
 
Join Date: Aug 2007
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
I think “Compression and Decompression of Files using Visual Basic 2005” article on
http://aspalliance.com/1287_Compress...Basic_2005.all
 may be helpful in this discussion.

This popular white paper is written by a software engineer from our organization Mindfire Solutions (http://www.mindfiresolutions.com).

I hope you find it useful!

Cheers,
Byapti










Similar Threads
Thread Thread Starter Forum Replies Last Post
tiff compression sandrina C# 2005 1 December 4th, 2013 02:42 AM
compression jaya_malini Java GUI 0 May 5th, 2005 10:01 AM
wav compression jothi Pro VB 6 0 April 26th, 2005 02:12 AM
Automation file not supported in visual basic sush_blr Beginning VB 6 2 December 28th, 2004 02:42 AM
File Compression: Automation xgbnow VB How-To 3 July 3rd, 2003 08:35 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.