home *** CD-ROM | disk | FTP | other *** search
- VERSION 2.00
- Begin Form Form1
- BackColor = &H00C0C0C0&
- BorderStyle = 1 'Fixed Single
- Caption = "WLZHCXP Example"
- ClientHeight = 3585
- ClientLeft = 1320
- ClientTop = 1485
- ClientWidth = 3795
- Height = 3990
- Icon = MAINSCRN.FRX:0000
- Left = 1260
- LinkMode = 1 'Source
- LinkTopic = "Form1"
- MaxButton = 0 'False
- ScaleHeight = 3585
- ScaleWidth = 3795
- Top = 1140
- Width = 3915
- Begin PictureBox Picture1
- BackColor = &H00FFFF00&
- Height = 1275
- Left = 120
- ScaleHeight = 1245
- ScaleWidth = 3525
- TabIndex = 8
- Top = 2220
- Width = 3555
- End
- Begin CommandButton Command7
- Caption = "E&xit"
- Height = 435
- Left = 1020
- TabIndex = 6
- Top = 1560
- Width = 1755
- End
- Begin CommandButton Command6
- Caption = "&Delete File"
- Height = 435
- Left = 1920
- TabIndex = 5
- Top = 1080
- Width = 1755
- End
- Begin CommandButton Command5
- Caption = "&Append Files"
- Height = 435
- Left = 120
- TabIndex = 4
- Top = 1080
- Width = 1755
- End
- Begin CommandButton Command4
- Caption = "C&opy File"
- Height = 435
- Left = 1920
- TabIndex = 3
- Top = 600
- Width = 1755
- End
- Begin CommandButton Command3
- Caption = "&Free Disk Space"
- Height = 435
- Left = 120
- TabIndex = 2
- Top = 600
- Width = 1755
- End
- Begin CommandButton Command2
- Caption = "&Decompress"
- Height = 435
- Left = 1920
- TabIndex = 1
- Top = 120
- Width = 1755
- End
- Begin CommandButton Command1
- Caption = "&Compress"
- Height = 435
- Left = 120
- TabIndex = 0
- Top = 120
- Width = 1755
- End
- Begin Label Label1
- BackColor = &H00C0C0C0&
- Caption = "Status"
- ForeColor = &H00FF0000&
- Height = 195
- Left = 120
- TabIndex = 7
- Top = 1980
- Width = 555
- End
- ' Compression routine. Also an example of GetFileSize()
- Sub Command1_Click ()
- ' Get size of original file
- insize& = GetFileSize("wlzhcxp.txt")
- Picture1.Cls
- ' If filesize is 0, there's a problem...
- If insize& = 0& Then
- Picture1.Print "You must copy WLZHCXP.TXT to the"
- Picture1.Print "same directory as this program"
- Picture1.Print "for the program to work"
- Exit Sub
- End If
- ' Display original file size
- Picture1.Print "WLZHCXP.TXT size = "; insize&; " bytes"
- ' Compress file into an output file
- x% = Compress("wlzhcxp.txt", "wlzhcxp.cmp")
- ' If an error occurred, display the fact and quit
- If x% <> LZH_OK Then
- Picture1.Print "Error #"; x%; " occurred while"
- Picture1.Print " compressing WLZHCXP.TXT"
- Exit Sub
- End If
- ' Display compressed size and compression percentage
- outsize& = GetFileSize("WLZHCXP.CMP")
- Picture1.Print "WLZHCXP.CMP size = "; outsize&; " bytes"
- Picture1.Print "Compression of ";
- Picture1.Print Format$(100 - ((outsize& / insize&) * 100), "##.##");
- Picture1.Print " percent"
- Picture1.Print " Compression Done"
- End Sub
- ' Decompression routine. You must first run Compress.
- Sub Command2_Click ()
- ' Get input file size
- insize& = GetFileSize("WLZHCXP.CMP")
- Picture1.Cls
- ' If unable to locate input file, display such.
- If insize& < 10 Then
- Picture1.Print "Unable to locate WLZHCXP.CMP"
- Picture1.Print "You must first run the Compress"
- Picture1.Print "routine to create the file!"
- Exit Sub
- End If
- ' Display byte size of input file
- Picture1.Print "WLZHCXP.CMP = "; insize&; " bytes"
- ' Decompress file into original size
- x% = Decompress("WLZHCXP.CMP", "WLZHCXP.OUT")
- ' If an error occurred, display it.
- If x% <> LZH_OK Then
- Picture1.Print "Decompress error #"; x%; " occurred"
- Exit Sub
- End If
- ' Display restored file byte size
- outsize& = GetFileSize("WLZHCXP.OUT")
- Picture1.Print "WLZHCXP.OUT = "; outsize&; " bytes"
- Picture1.Print " Decompression Done"
- End Sub
- ' GetFreeDiskSpace() example routine. C: drive only
- ' in this case.
- Sub Command3_Click ()
- ' Get space on C: drive.
- freesp& = GetFreeDiskSpace("C:")
- Picture1.Cls
- ' Display free space found on C: drive.
- Picture1.Print freesp&; " bytes free on C:"
- Picture1.Print " Done"
- End Sub
- ' Copy WLZHCXP.TXT to WLZHCXP.OUT
- Sub Command4_Click ()
- x% = CopyFile("WLZHCXP.TXT", "WLZHCXP.OUT")
- Picture1.Cls
- If x% <> LZH_OK Then
- Picture1.Print "Copy error #"; x%; ";"; occurred; ""
- Exit Sub
- End If
- Picture1.Print "WLZHCXP.TXT -> WLZHCXP.OUT"
- Picture1.Print " Done"
- End Sub
- ' Example of AppendFile() function
- Sub Command5_Click ()
- ' Get size of WLZHCXP.OUT
- insize& = GetFileSize("wlzhcxp.out")
- Picture1.Cls
- ' If bad file or no file, tell user and quit
- If insize& < 10 Then
- Picture1.Print "Unable to locate WLZHCXP.OUT"
- Picture1.Print "Run Copy function first."
- Exit Sub
- End If
- ' Get WLZHCXP.TXT file size
- Picture1.Print "WLZHCXP.OUT = "; insize&; " bytes"
- insize& = GetFileSize("WLZHCXP.TXT")
- If insize& < 3 Then
- Picture1.Print "Unable to locate WLZHCXP.TXT"
- Picture1.Print "Copy the file to the same directory"
- Picture1.Print "as this program and run Copy."
- Exit Sub
- End If
- ' Display file size for second file
- Picture1.Print "WLZHCXP.TXT = "; insize&; " bytes"
- ' Add WLZHCXP.TXT to WLZHCXP.OUT
- x% = AppendFile("WLZHCXP.OUT", "WLZHCXP.TXT")
- ' If an error occurred, tell user
- If x% <> LZH_OK Then
- Picture1.Print "Append error #"; x%; " occurred"
- Exit Sub
- End If
- ' Display complete file size and exit
- insize& = GetFileSize("WLZHCXP.OUT")
- Picture1.Print "New WLZHCXP.OUT = "; insize&; " bytes"
- Picture1.Print " Append done."
- End Sub
- ' DeleteFile() example
- Sub Command6_Click ()
- ' Get size of file to delete
- insize& = GetFileSize("WLZHCXP.OUT")
- Picture1.Cls
- ' If bad file or no file, tell user and exit
- If insize& < 10 Then
- Picture1.Print "Unable to locate WLZHCXP.OUT"
- Picture1.Print "Try running Copy first"
- Exit Sub
- End If
- ' Delete file
- x% = DeleteFile("WLZHCXP.OUT")
- ' If error, tell user and exit
- If x% <> LZH_OK Then
- Picture1.Print "Delete error "; x%; " occurred."
- Exit Sub
- End If
- ' Tell user the file's gone bye-bye
- Picture1.Print "WLZHCXP.OUT deleted"
- Picture1.Print " Done"
- End Sub
- Sub Command7_Click ()
- End
- End Sub
-