Option Explicit
Const OF_CREATE = &H1000
Const OF_READ = &H0
Const OFS_MAXPATHNAME = 128
Private Type OFSTRUCT
cBytes As Byte
fFixedDisk As Byte
nErrCode As Integer
Reserved1 As Integer
Reserved2 As Integer
szPathName(OFS_MAXPATHNAME) As Byte
End Type
Private Declare Sub LZClose Lib "lz32.dll" _
(ByVal hfFile As Long)
Private Declare Function LZCopy Lib "lz32.dll" _
(ByVal hfSource As Long, ByVal hfDest As Long) As Long
Private Declare Function LZOpenFile Lib "lz32.dll" Alias "LZOpenFileA" _
(ByVal lpszFile As String, lpOf As OFSTRUCT, ByVal style As Long) _
As Long
Public Sub CopyFile(Source As String, Destination As String)
Dim hsource As Long
Dim hdest As Long
Dim iret As Long
Dim OpenStruct As OFSTRUCT
' Open the source and destination files.
hsource = LZOpenFile(Source, OpenStruct, OF_READ)
hdest = LZOpenFile(Destination, OpenStruct, OF_CREATE)
' Copy the source file to the destination location, and
' decompress the Source file if it was compressed.
iret = LZCopy(hsource, hdest)
' Close the files.
LZClose hdest
LZClose hsource
If iret = -1 Then
MsgBox "File transfer failed"
Else
MsgBox "Transfer successful: " _
& Format$(iret, "###,###,###,###") _
& " bytes were transferred."
End If
End Sub
Private Sub Command1_Click()
CopyFile Text1.Text, Text2.Text
End Sub
Private Sub Form_Load()
Label1.Caption = "Source Directory and Filename"
Label2.Caption = "Target Directory and Filename"
Command1.Caption = "Copy"
End Sub