请教高手:VB dll 调用约定错误!!
各位高手,我的VB调用DLL,在运行时出现了 dll 调用约定错误! 程序如下,请各位大虾帮忙解决一下!!感恩。。VB程序:
Option Explicit
'USB User Interface
Public Declare Function Read_USB Lib "DS5000USB_UI.dll" (ByVal mType As Long, ByVal wLength As Long, pBuffer As Any) As Boolean
Public Declare Function Write_USB Lib "DS5000USB_UI.dll" (ByVal cChar As Long) As Boolean
Global Const USB_READ_CMD_REDAY = 0
Global Const USB_READ_CMD_DATA = 1
Global Const ARRAYSIZE = 1024 ' Size of read buffer
Global DSO_IOInitOK As Boolean
Global USB_TimeOutTimer As Long 'USB?????á???±??
Sub USB_Init()
' ========================================================================
'
' INITIALIZATION SECTION
'
' ========================================================================
' The application brings the oscilloscope online using ildev. A
' device handle, Dev, is returned and is used in all subsequent
' calls to the device.
Dim retcode As Boolean
Dim ValueStr As String * ARRAYSIZE
Dim buf(255) As Byte
' The application reads the ASCII string from the oscilloscope
' into the ValueStr variable.
retcode = Read_USB(USB_READ_CMD_REDAY, 1, buf(0))
If retcode = False Then
MsgBox "Cann't Connect to USB Device", 48, "USB Init"
DSO_IOInitOK = False
Else
DSO_IOInitOK = True
End If
End Sub
Sub SendToUSB(cmd As String)
Dim retcode As Boolean
Dim buf As String
Dim temp As Long
Dim i As Integer
buf = cmd + Chr$(13)
' The application writes the text in ScopeCommand to the
' oscilloscope.
For i = 1 To Len(cmd) + 1
temp = Asc(buf)
buf = Right(buf, Len(cmd) + 1 - i)
retcode = Write_USB(temp)
If retcode = False Then
MsgBox "Cann't Connect to USB Device", 48, "USB Send Message"
Exit For
End If
Next i
End Sub
Public Function ReadUSB() As String
Dim retcode As Boolean
Dim tmpStr As String
Dim buffer(256) As Byte
Dim i, size As Long
' The application reads the ASCII string from the oscilloscope
' into the ValueStr variable.
USB_TimeOutTimer = 0
buffer(0) = 0
While (buffer(0) = 0 And USB_TimeOutTimer < 20)
retcode = Read_USB(USB_READ_CMD_REDAY, 1, buffer(0))
If retcode = False Then
MsgBox "Can't Connect to USB Device", 48, "USB Read Message"
ReadUSB = ""
Exit Function
End If
DoEvents
Wend
If USB_TimeOutTimer > 19 Then
MsgBox "Read USB time out", 48, "USB Read Message"
tmpStr = ""
Else
size = buffer(0)
retcode = Read_USB(USB_READ_CMD_DATA, size, buffer(0))
If retcode = False Then
MsgBox "Cann't Connect to USB Device", 48, "USB Read Message"
ReadUSB = ""
Exit Function
End If
tmpStr = ""
For i = 0 To size - 1
If (buffer(i) = 10) Then
Exit For
End If
tmpStr = tmpStr + Chr(buffer(i))
Next i
End If
ReadUSB = tmpStr
End Function
DLL函数定义:
附件(DLL头文件)