求助:翻译计算机收发短信源码
给几台水泵安装了GSM开关,拟用计算机+短信猫控制,买了一个WAVECOM的GSM MODEM,但厂家只有支持VB的软件开发工具包,而我仅会VFP,现请求高手将其中的调用SMS.DLL及其接收、发送短信这一部分VB源码告知,我试着将其转换为VFP。谢谢。
现将厂家给的支持VB的软件开发工具包用WINRAR压缩后上传,文件很小,只有648K。http://www.vdisk.cn/down/index/15069827
短信 gsm vb 源码
[解决办法]
这是函数声明部分,看看是不是你想要的!
Option Strict Off
Option Explicit On
Module loadsms
'短信收发二次开发接口(标准版)函数使用说明
'Sms_Connection函数说明如下:
'功能描述:用于初始化移动电话与串口的连接
'Com_Port:串口号
'Com_BaudRate:波特率
'Mobile_Type:返回移动电话型号
'Sms_Connection:返回值(0:连接移动电话失败;1:连接移动电话成功)
'******************************************************
'******************************************************
'Sms_Send函数说明如下:
'功能描述:发送短信
'Sms_TelNum:发送给的移动电话号码
'Sms_Text:发送的短信内容
'Sms_Connection:返回值(0:发送短信失败;1:发送短信成功)
'******************************************************
'******************************************************
'Sms_Receive函数说明如下:
'功能描述:接收指定类型的短信
'Sms_Type:短信类型(0:未读短信;1:已读短信;2:待发短信;3:已发短信;4:全部短信)
'Sms_Text:返回指定类型的短信内容字符串(短信内容字符串说明:短信与短信之前用"
[解决办法]
"符号作为分隔符,每条短信中间的各字段用"#"符号作为分隔符)
'******************************************************
'******************************************************
'Sms_Delete函数说明如下:
'功能描述:删除指定的短信
'Sms_Index:短信的索引号
'******************************************************
'******************************************************
'Sms_AutoFlag函数说明如下:
'功能描述:检测连接的移动电话是否支持自动收发短信功能
'Sms_AutoFlag:返回值(0:不支持;1:支持)
'******************************************************
'******************************************************
'Sms_NewFlag函数说明如下:
'功能描述:查询是否收到新的短信息
'Sms_AutoFlag:返回值(0:未收到;1:收到)
'******************************************************
'******************************************************
'Sms_Disconnection函数说明如下:
'功能描述:断开移动电话与串口的连接
'******************************************************
Public Declare Function Sms_Connection Lib "sms.dll" (ByVal CopyRight As String, ByVal Com_Port As Short, ByVal Com_BaudRate As Short, ByRef Mobile_Type As String, ByRef CopyRightToCOM As String) As Integer
Public Declare Function Sms_Send Lib "sms.dll" (ByVal Sms_TelNum As String, ByVal Sms_Text As String) As Integer
Public Declare Function Sms_Receive Lib "sms.dll" (ByVal Sms_Type As String, ByRef Sms_Text As String) As Integer
Public Declare Function Sms_Delete Lib "sms.dll" (ByVal Sms_Index As String) As Integer
Public Declare Function Sms_AutoFlag Lib "sms.dll" () As Integer
Public Declare Function Sms_NewFlag Lib "sms.dll" () As Integer
Public Declare Function Sms_Disconnection Lib "sms.dll" () As Integer
End Module
'UPGRADE_WARNING: Screen 属性 Screen.MousePointer 具有新的行为。 单击以获得更多信息:'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2065"'
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
Sms_Send_Button.Enabled = False
If Len(Trim(TelNum_Text.Text)) >= 11 And Sms_Send(Trim(TelNum_Text.Text), Trim(SendSms_Text.Text)) Then
MsgBox("发送短信成功!", MsgBoxStyle.Information, "提示")
Else
MsgBox("发送短信失败!", MsgBoxStyle.Critical, "警告")
End If
Sms_Send_Button.Enabled = True
'UPGRADE_WARNING: Screen 属性 Screen.MousePointer 具有新的行为。 单击以获得更多信息:'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2065"'
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
'UPGRADE_WARNING: Screen 属性 Screen.MousePointer 具有新的行为。 单击以获得更多信息:'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2065"'
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
Sms_Receive_Button.Enabled = False
Dim ReceiveSmsStr As String
If Sms_Receive("4", ReceiveSmsStr) Then
ReceiveSms_Text.Text = ReceiveSmsStr
End If
Sms_Receive_Button.Enabled = True
If Sms_AutoFlag() Then
If Sms_Start_Button.Enabled = True Then
NewSms_Show.Text = "自动接收短信功能处于关闭状态"
Else
NewSms_Show.Text = "未收到新短信"
End If
Else
NewSms_Show.Text = "该短信猫不支持自动接收短信功能"
End If
'UPGRADE_WARNING: Screen 属性 Screen.MousePointer 具有新的行为。 单击以获得更多信息:'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2065"'
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
'UPGRADE_ISSUE: 不支持 Load 语句。 单击以获得更多信息:'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup1039"'
'Load(Me)
'UPGRADE_WARNING: Screen 属性 Screen.MousePointer 具有新的行为。 单击以获得更多信息:'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2065"'
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
Sms_Connection_Button.Enabled = False
Dim TypeStr As String
Dim CopyRightToCOMStr As String
Dim CopyRightStr As String
CopyRightStr = "//上海迅赛信息技术有限公司,网址www.xunsai.com//"
If Sms_Connection(CopyRightStr, CShort(MobPort.Text), 9600, TypeStr, CopyRightToCOMStr) Then '若使用诺基亚移动电话,请使用数据套件虚拟串口连接
State_Show.Text = "连接短信猫成功" & Chr(10) & "(短信猫型号为:" & TypeStr & ")"
Sms_Send_Button.Enabled = True
Sms_Receive_Button.Enabled = True
Sms_Delete_Button.Enabled = True
SendSms_Text.Enabled = True
TelNum_Text.Enabled = True
ReceiveSms_Text.Enabled = True
DeleteSms_Index.Enabled = True
Sms_Disconnection_Button.Enabled = True
Sms_Start_Button.Enabled = True
NewSms_Show.Text = "自动接收短信功能处于关闭状态"
NewSms_Show.Enabled = True
NewSms_Timer.Enabled = False
Else
State_Show.Text = "连接短信猫失败" & Chr(10) & "(请重新连接短信猫)"
Sms_Connection_Button.Enabled = True
End If
'UPGRADE_WARNING: Screen 属性 Screen.MousePointer 具有新的行为。 单击以获得更多信息:'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2065"'
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
If Sms_AutoFlag() Then
NewSms_Show.Text = "未收到新短信"
Sms_Start_Button.Enabled = False
Sms_Close_Button.Enabled = True
NewSms_Timer.Enabled = True
Else
NewSms_Show.Text = "该短信猫不支持自动接收短信功能"
End If
NewSms_Show.Text = "自动接收短信功能处于关闭状态"
Sms_Start_Button.Enabled = True
NewSms_Timer.Enabled = False
Sms_Close_Button.Enabled = False
'UPGRADE_WARNING: Screen 属性 Screen.MousePointer 具有新的行为。 单击以获得更多信息:'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2065"'
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
Sms_Disconnection_Button.Enabled = False
Sms_Disconnection()
Sms_Connection_Button.Enabled = True
Sms_Send_Button.Enabled = False
Sms_Receive_Button.Enabled = False
Sms_Delete_Button.Enabled = False
SendSms_Text.Enabled = False
TelNum_Text.Enabled = False
ReceiveSms_Text.Enabled = False
DeleteSms_Index.Enabled = False
Sms_Start_Button.Enabled = False
Sms_Close_Button.Enabled = False
State_Show.Text = ""
NewSms_Show.Text = ""
NewSms_Show.Enabled = False
NewSms_Timer.Enabled = False
'UPGRADE_WARNING: Screen 属性 Screen.MousePointer 具有新的行为。 单击以获得更多信息:'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2065"'
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
'UPGRADE_WARNING: Screen 属性 Screen.MousePointer 具有新的行为。 单击以获得更多信息:'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2065"'
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.WaitCursor
Sms_Delete_Button.Enabled = False
Sms_Delete(Trim(DeleteSms_Index.Text))
Sms_Delete_Button.Enabled = True
'UPGRADE_WARNING: Screen 属性 Screen.MousePointer 具有新的行为。 单击以获得更多信息:'ms-help://MS.VSCC/commoner/redir/redirect.htm?keyword="vbup2065"'
System.Windows.Forms.Cursor.Current = System.Windows.Forms.Cursors.Default
If Sms_NewFlag() Then
NewSms_Show.Text = "收到新短信,请查收!"
End If