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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how can i zip a file programatically using VB6?

Status
Not open for further replies.

Oliver76

Programmer
Oct 2, 2001
60
Good day!

I have a simple program using MSAccess as my backend and VB6 on my front. NOw, my probs is that i cant zip my msaccess backend using VB6 coding... pls help... any sample codes? tnx a lot in advance.

oliver
 
I dont think theres any way to do it within the code. (Id like to be corrected but...)

So you need to execute an external third party product refer thread711-557154 amongs others.
 
As a general idea - there SHOULD be some dll, may be component.
But - have no idea as to where to search.
 
Just use the Shell command to run Winzip from the command line. Shell runs external executables from within VB. For instance:

Shell "notepad.exe fred.txt", vbNormalFocus

will run Notepad, with fred.txt as its argument, and show it with normal focus. Look up Shell in VBHelp for the variations

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'People who live in windowed environments shouldn't cast pointers.'
 
Hello
I have an ocx and full source code for zip utility.
If u need please send me your mail id, i will mail u the full source code.

Regards
Som
 
FIRST DOWNLOAD THE WINZIp COMMAND LINE SUPPORT FROM -

and try this. . i haven't. but i feel it will do good. . .


The WinZip® Command Line Support Add-On lets you use WinZip's power from batch files, macros, and other situations when you have a specific task and would prefer to accomplish it quickly or automatically, without using the usual WinZip graphical user interface.
Two executable files implement the WinZip Command Line Support Add-On: WZZIP.EXE (for zipping) and WZUNZIP.EXE (for unzipping). This help file describes how to use WZZIP and WZUNZIP. It includes sections on Using WZUNZIP and Using WZZIP plus comprehensive reference sections listing all commands and options in alphabetical order. The two reference sections are directly accessible for browsing as the WZUNZIP reference and WZZIP reference.

See also the sections on Copyright, License, Warranty and Technical Support.

Using the WinZip Command Line Support Add-On
The WinZip Command Line Support Add-On is used by executing a command that starts WZZIP or WZUNZIP. There are three "places" where you can use the Add-On:

· In a command window, sometimes known as a DOS window or DOS box. This is a separate window that is normally started by selecting "MS-DOS Prompt" or "Command Prompt" from the Start menu; it normally displays the C> prompt.
· From the Run dialog, accessed from the Start menu.
· In batch files or other scripts (such as application program macros).

The exact format of the command depends on which of these you use.

Using a command window

You can use the Add-On in a command window in any of these ways:

· You can type the full name of the WinZip folder followed by the name of the command, which is either "WZZIP" (for zipping) or "WZUNZIP" (for unzipping), followed by the parameters necessary for the operation. For example, if you installed WinZip into the C:\Program Files\WinZip folder and you want to list the contents of MyFile.zip, you might type:

"c:\program files\winzip\wzzip" -v MyFile.zip

(Note that you must use quotes around the command name if the name of the folder includes spaces, as shown above. Otherwise, the quotes are not necessary.)

· You can copy WZZIP.EXE and WZUNZIP.EXE to a folder specified in your PATH environment variable. Then you can run the commands by simply typing "WZZIP" or "WZUNZIP" and the desired parameters, without the name of the WinZip folder:

wzzip -v filename.zip
· You can add the WinZip folder to your PATH environment variable, for example:

set path=c:\windows;c:\program files\winzip;...

If you have done this, you can run the commands at the system prompt by simply typing "WZZIP" or "WZUNZIP" followed by the desired parameters, without the name of the WinZip folder:

wzzip -v filename.zip

(For information on the PATH environment variable, please refer to your Windows documentation. If you use this method regularly, you will probably want to edit AUTOEXEC.BAT so that the WinZip folder is permanently added to the PATH environment variable.)


Using the Run dialog

You can use WZZIP.EXE and WZUNZIP.EXE from the Run dialog by simply typing the command name and any desired parameters. It is not necessary to include the WinZip folder, but you may need to specify the folder for the files you wish to work with. For example:


wzzip -yp -v c:\temp\filename.zip

We recommend using the -yp option to keep the MS-DOS command prompt window from closing automatically; otherwise, you will not have much time to look at the results of your command.

Using batch files

You can use WZZIP.EXE and WZUNZIP.EXE in MS-DOS batch files using the same rules as shown above for command windows.

The procedure will be similar for script processors other than MS-DOS batch files (application program macros, for example). However, check your documentation for information on how paths should be specified.

Using return codes (errorlevels)

WZZIP and WZUNZIP will in most cases return a nonzero errorlevel in the event of a serious error; otherwise, an errorlevel of 0 is returned. You can use these return codes in batch files and other automated processing. For example:

wzzip filename.zip *.doc
If Not ErrorLevel 1 Goto Exit
Echo ***SERIOUS ERROR DETECTED***
:Exit

Copyright © 2000 WinZip Computing, Inc. All rights reserved.
 
thanx a lot 2 U guys, shell command really helped me... :)
 
My 2 cents worth, hope this helps :)

I had the same issue and found WinZip quite good.
Especially if you need to compress the file with password protection! Combining this with OSSMTP.dll I now compress the file and email it off for the user which works nicely showing the user messages as each step is completed.

I also added some code to check if WinZip was present /installed and the file to compress is present.

Snippet:

Code:
'Create password protected zip file via Winzip

Call Shell("C:\Program Files\WinZip\winzip32 -a -ex -s" & strCompressPassword & " " & _
strWorkingDirectory & "\" & strCompressedFileName & " " & strWorkingDirectory & "\" & strSendFileName)
                          
sStepName = "Source file " + strSendFileName + " successfully compressed and password protected"

Call PutMsg(vbCrLf + sStepName)


Rob Hasard
(VB6 /SQL 7.0 /CR8.5)
 
When I ran into this, WinZip wanted a whole lot of money as I recall to redistribute for sale. I found XZip.dll does everything I need, and it's freeware. I've used it in a distributed for sale application with no problems as yet. if you're interested.
 
Silly question but why don't you use LZ32.DLL and/or LZEXPAND.DLL? I'm currently on a WinME machine and located these two in the \\Windows\System\ directory. As far as I know one (or both) come with the installation of Windows on a system.

Here's a snippet from the VB4's WIN32API.TXT file:
(YES, I said [red]VB4[/red]!)

******************************************************************************************************
' public interface to LZEXP?.LIB

' LZEXPAND error return codes
Public Const LZERROR_BADINHANDLE = (-1) ' invalid input handle
Public Const LZERROR_BADOUTHANDLE = (-2) ' invalid output handle
Public Const LZERROR_READ = (-3) ' corrupt compressed file format
Public Const LZERROR_WRITE = (-4) ' out of space for output file
Public Const LZERROR_PUBLICLOC = (-5) ' insufficient memory for LZFile struct
Public Const LZERROR_GLOBLOCK = (-6) ' bad Global handle
Public Const LZERROR_BADVALUE = (-7) ' input parameter out of range
Public Const LZERROR_UNKNOWNALG = (-8) ' compression algorithm not recognized

Declare Function LZCopy Lib "lz32.dll" Alias "LZCopy" (ByVal hfSource As Long, ByVal hfDest As Long) As Long
Declare Function LZInit Lib "lz32.dll" Alias "LZInit" (ByVal hfSrc As Long) As Long
Declare Function GetExpandedName Lib "lz32.dll" Alias "GetExpandedNameA" (ByVal lpszSource As String, ByVal lpszBuffer As String) As Long
Declare Function LZOpenFile Lib "lz32.dll" Alias "LZOpenFileA" (ByVal lpszFile As String, lpOf As OFSTRUCT, ByVal style As Long) As Long
Declare Function LZSeek Lib "lz32.dll" Alias "LZSeek" (ByVal hfFile As Long, ByVal lOffset As Long, ByVal nOrigin As Long) As Long
Declare Function LZRead Lib "lz32.dll" Alias "LZRead" (ByVal hfFile As Long, ByVal lpvBuf As String, ByVal cbread As Long) As Long
Declare Sub LZClose Lib "lz32.dll" Alias "LZClose" (ByVal hfFile As Long)
******************************************************************************************************

And some people still ask me: "Why do you have THAT!! old thing?" Then I think to myself, "Cause one day you'll need it! and you'll come running"

HTH
--MiggyD

--> It's a bird! It's a plane! No, it's an OS update patch! Ahh!! <--
 
MiggyD said:
I'm currently on a WinME machine
Wow I didn't know those still existed, don't throw the disk away it may be worth something someday just like currency with defects.;-)


Two strings walk into a bar. The first string says to the bartender: 'Bartender, I'll have a beer. u.5n$x5t?*&4ru!2[sACC~ErJ'. The second string says: 'Pardon my friend, he isn't NULL terminated'.
 
We've covered the LZ functions in here before. Trouble is that there is one important one missing: LZWrite
 
You can find a free activex zip component here: XStandard Software


Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
There's another free activex zip component here: HDSE Software

Tracy Dryden

Meddle not in the affairs of dragons,
For you are crunchy, and good with mustard. [dragon]
 
You can find a free activex zip component here: XStandard Software

I've used that in a publicly distributed application, with no difficulties.

Bob
 
May I ask how you've accomplished that ? I only see code for ASP on the site, is it similar for Visual Basic 6 ?

Do I need to register that dll in order to use it ? And if so, how can I redistribute the dll an register it on installation of my application ?

Many thanks, and as you may have noticed, I'm still new to visual basic...

Beess
 
Have you tried adding the *.dll to your project on the components form ?, I haven't as of yet, but I would imagine it would work,
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top