home *** CD-ROM | disk | FTP | other *** search
- Attribute VB_Name = "Module1"
- ' Constants with OpenFile API call.
- Private Const OF_WRITE = &H1
- Private Const OF_READ = &H0
- Private Const OF_CREATE = &H1000
-
- ' Structure filled in by OpenFile API call.
- Private Type OFSTRUCT
- cBytes As Byte
- fFixedDisk As Byte
- nErrCode As Integer
- Reserved1 As Integer
- Reserved2 As Integer
- szPathName(128) As Byte
- End Type
-
- ' declarations for the API functions that this class uses.
- Private Declare Function OpenFile Lib "kernel32" _
- (ByVal lpFileName As String, _
- lpReOpenBuff As OFSTRUCT, _
- ByVal wStyle As Long) As Long
-
- Private Declare Function hread Lib "kernel32" Alias "_hread" _
- (ByVal hFile As Long, lpBuffer As Any, ByVal lBytes As Long) As Long
-
- Private Declare Function hwrite Lib "kernel32" Alias "_hwrite" _
- (ByVal hFile As Long, ByVal lpBuffer As String, ByVal lBytes As Long) As Long
-
- Private Declare Function lclose Lib "kernel32" Alias "_lclose" _
- (ByVal hFile As Long) As Long
-
- Private inpOFS As OFSTRUCT
- Private outOFS As OFSTRUCT
- Private myBuf As String
- Private size As Long
-
- Public Sub firstCopy(inp As String, out As String)
- Dim hInp As Long
- Dim hOut As Long
-
- size = FileLen(inp)
- myBuf = String(size, "*")
- hInp = OpenFile(inp, inpOFS, OF_READ)
- hOut = OpenFile(out, outOFS, OF_CREATE Or OF_WRITE)
- If (hInp <> -1 And hOut <> -1) Then
- hread hInp, ByVal myBuf, size
- hwrite hOut, ByVal myBuf, size
- End If
- lclose hOut
- lclose hInp
- End Sub
-
- Public Sub additionalCopy(out As String)
- Dim hOut As Long
-
- hOut = OpenFile(out, outOFS, OF_CREATE Or OF_WRITE)
- If (hOut <> -1) Then
- hwrite hOut, ByVal myBuf, size
- End If
- lclose hOut
- End Sub
-
-