各位大侠:
按照帮助文件的提示 ,我想连接一款短信猫,对方提供了sms.dll,并给了内函数说明
我仿照提示做了如下操作
1、定义了api
Public Declare Function Sms_Connection Lib "sms.dll" Alias "Sms_Connection" (ByVal Port As Integer,Com_BaudRate As Integer, Mobile_Type As String) As Integer '连接设备
2、在窗口加载时使用了如下代码:
Try
Dim lb1 As WinForm.Label = e.Form.Controls("Label1")
Dim iRetUSB As Integer
For iPort As Integer = 1 To 1016 '遍历端口号
iRetUSB = Sms_Connection(iPort,1,"")
' MessageBox.Show( Sms_Connection(1,1000,"") )
If iRetUSB = 1 Then
Exit For
End If
Next
If iRetUSB = 1 Then
lb1.Text = "设备连接成功"
Else
lb1.Text = "设备连接失败"
End If
Catch ex As Exception
'MessageBox.Show(ex.ToString)
End Try
3、执行没反应
好像Sms_Connection不起作用
对于Sms_Connection的说明:
Sms_Connection(Com_Port As Integer,Com_BaudRate As Integer, Mobile_Type As String) As Integer
Sms_Connection函数说明如下:
功能描述:用于初始化终端与串口的连接
Com_Port:串口号(0为红外接口,1,2,3,...为串口)
Com_BaudRate:波特率
Mobile_Type:返回终端型号
Sms_Connection:返回值(0:连接终端失败;1:连接终端成功)
各位 我这样做对吗?能给些提示吗?谢谢