TPetersonFlorida
Programmer
My problem I'm having is everytime i call the CopyMemory i get a GPF and crashes my app. ANY help would be greatly appreciated. Here is my code:
Declare Function BTRCALL Lib "w3btrv7.dll" (ByVal OP, ByVal Pb$, Db As Any, DL As Integer, Kb As Any, ByVal Kl, ByVal Kn) As Integer
Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Type typ_byte4
f1(1 To 4) As Byte
End Type
Type RecordBuffer
Junk1 As String * 6
MilID As String * 10
MilNumber As String * 2
MilSymbol As String * 1
MilDesc As String * 40
MilWeight As String * 8
MilSchedDate As Long
MilForcastDate As Long
MilCompleteFlag As String * 1
MilPctComplete As String * 3
MilWBS As Long
Junk2 As String * 7
End Type
Type RecordBufferTodd
Junk1 As String * 6
MilID As String * 10
MilNumber As String * 2
MilSymbol As String * 1
MilDesc As String * 40
MilWeight As String * 8
MilSchedDate As typ_byte4
MilForcastDate As typ_byte4
MilCompleteFlag As String * 1
MilPctComplete As String * 3
MilWBS As typ_byte4
Junk2 As String * 7
End Type
Global DataBufVB As RecordBuffer
Global DataBuf As RecordBufferTodd
Global BufLen As Integer
Global DBLen As Integer
Sub RunTest()
'FileName$ = CurrentProject.Path & "\Todda.mil"
FileName$ = "z:\acct\mpm\wld1\Todda.mil"
PosBlk$ = Space$(128)
KeyBuffer$ = Space$(KEY_BUF_LEN)
'Open File
KeyBufLen = KEY_BUF_LEN
KeyBuffer$ = FileName$
BufLen = Len(DataBuf)
KeyNum = 0
status = BTRCALL(BOPEN, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, KeyNum)
'Get First Record
BufLen = Len(DataBuf)
KeyBuffer$ = Space$(255)
KeyBufLen = KEY_BUF_LEN
status = BTRCALL(BGETFIRST, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, 0)
Do While (status = 0)
status = BTRCALL(BGETNEXT, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, 0)
GoSub AddRecord
Loop
Exit Sub
AddRecord:
DataBufVB.Junk1 = DataBuf.Junk1
DataBufVB.Junk2 = DataBuf.Junk2
DataBufVB.MilCompleteFlag = DataBuf.MilCompleteFlag
DataBufVB.MilDesc = DataBuf.MilDesc
DataBufVB.MilID = DataBuf.MilID
DataBufVB.MilNumber = DataBuf.MilNumber
DataBufVB.MilPctComplete = DataBuf.MilPctComplete
DataBufVB.MilSymbol = DataBuf.MilSymbol
DataBufVB.MilWeight = DataBuf.MilWeight
CopyMemory DataBuf.MilForcastDate, ByVal DataBufVB.MilForcastDate, 4
Return
End Sub
Declare Function BTRCALL Lib "w3btrv7.dll" (ByVal OP, ByVal Pb$, Db As Any, DL As Integer, Kb As Any, ByVal Kl, ByVal Kn) As Integer
Declare Sub CopyMemory Lib "KERNEL32" Alias "RtlMoveMemory" (hpvDest As Any, hpvSource As Any, ByVal cbCopy As Long)
Type typ_byte4
f1(1 To 4) As Byte
End Type
Type RecordBuffer
Junk1 As String * 6
MilID As String * 10
MilNumber As String * 2
MilSymbol As String * 1
MilDesc As String * 40
MilWeight As String * 8
MilSchedDate As Long
MilForcastDate As Long
MilCompleteFlag As String * 1
MilPctComplete As String * 3
MilWBS As Long
Junk2 As String * 7
End Type
Type RecordBufferTodd
Junk1 As String * 6
MilID As String * 10
MilNumber As String * 2
MilSymbol As String * 1
MilDesc As String * 40
MilWeight As String * 8
MilSchedDate As typ_byte4
MilForcastDate As typ_byte4
MilCompleteFlag As String * 1
MilPctComplete As String * 3
MilWBS As typ_byte4
Junk2 As String * 7
End Type
Global DataBufVB As RecordBuffer
Global DataBuf As RecordBufferTodd
Global BufLen As Integer
Global DBLen As Integer
Sub RunTest()
'FileName$ = CurrentProject.Path & "\Todda.mil"
FileName$ = "z:\acct\mpm\wld1\Todda.mil"
PosBlk$ = Space$(128)
KeyBuffer$ = Space$(KEY_BUF_LEN)
'Open File
KeyBufLen = KEY_BUF_LEN
KeyBuffer$ = FileName$
BufLen = Len(DataBuf)
KeyNum = 0
status = BTRCALL(BOPEN, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, KeyNum)
'Get First Record
BufLen = Len(DataBuf)
KeyBuffer$ = Space$(255)
KeyBufLen = KEY_BUF_LEN
status = BTRCALL(BGETFIRST, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, 0)
Do While (status = 0)
status = BTRCALL(BGETNEXT, PosBlk$, DataBuf, BufLen, ByVal KeyBuffer$, KeyBufLen, 0)
GoSub AddRecord
Loop
Exit Sub
AddRecord:
DataBufVB.Junk1 = DataBuf.Junk1
DataBufVB.Junk2 = DataBuf.Junk2
DataBufVB.MilCompleteFlag = DataBuf.MilCompleteFlag
DataBufVB.MilDesc = DataBuf.MilDesc
DataBufVB.MilID = DataBuf.MilID
DataBufVB.MilNumber = DataBuf.MilNumber
DataBufVB.MilPctComplete = DataBuf.MilPctComplete
DataBufVB.MilSymbol = DataBuf.MilSymbol
DataBufVB.MilWeight = DataBuf.MilWeight
CopyMemory DataBuf.MilForcastDate, ByVal DataBufVB.MilForcastDate, 4
Return
End Sub