我在VB 6.0上模仿CH372DBG\DOWNFILE\WINDOWS下的Transfile函数,一直都接不到数据,头痛啊! 请指点一二!! Private Function TransFile(ByVal hWnd As Long) As Boolean
Dim ReadLen As Long Dim mLen As Long mLen = 0 Dim by As Byte Dim bylen As Long by = 0 bylen = 0 Trb = 0 Dim Writebuff As mBuff mTotal = 1 Writebuff.mBuff(0) = 0
Dim sb As OVERLAPPED With sb .Internal = 0 .InternalHigh = 0 .offset = 0 .OffsetHigh = 0 .hEvent = 0 End With 'Dim addr As Long Call CH375Writedata(0, mBuffer, mTotal) Do While (1) ReadLen = 1024 Call ReadFile(hWnd, mBuffer, 1024, ReadLen, sb)
If (ReadLen < 1024) Then mLen = ReadLen On Error Resume Next If (CH375Writedata(0, mBuffer, mLen)) Then If (mLen <> 0) Then Trb = Trb + 1 End If MsgBox "写结束 " & Trb & "K" Exit Do Else MsgBox "写数据失败" Exit Do End If Else mLen = ReadLen On Error Resume Next If (CH375Writedata(0, mBuffer, mLen)) Then If (mLen <> 0) Then Trb = Trb + 1 End If MsgBox "写结束 " & Trb & "K" Else MsgBox "写数据失败" ' Exit Do End If End If TransFile = False
'Else Loop 'Loop
End Function