📄 form1.frm
字号:
VERSION 5.00
Begin VB.Form Form1
Caption = "金仓短信标准接口(SDK2.x)——VB6开发示例"
ClientHeight = 8670
ClientLeft = 60
ClientTop = 345
ClientWidth = 10560
LinkTopic = "Form1"
ScaleHeight = 8670
ScaleWidth = 10560
StartUpPosition = 2 '屏幕中心
Begin VB.CommandButton Command5
Caption = "退出"
Height = 375
Left = 9120
TabIndex = 29
Top = 8160
Width = 1095
End
Begin VB.TextBox status1
BackColor = &H80000000&
Height = 375
Left = 1560
TabIndex = 23
Top = 8160
Width = 7335
End
Begin VB.Frame Frame3
Caption = "接收短信测试"
Height = 2415
Left = 0
TabIndex = 10
Top = 5520
Width = 10455
Begin VB.CheckBox isClear
Caption = "清空短信"
Height = 375
Left = 9120
TabIndex = 28
Top = 840
Value = 1 'Checked
Width = 1215
End
Begin VB.CommandButton Command4
Caption = "接收短信"
Height = 375
Left = 9120
TabIndex = 18
Top = 360
Width = 1095
End
Begin VB.TextBox jsnr
Height = 1215
Left = 1560
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 17
Top = 360
Width = 7335
End
Begin VB.Label Label8
BackColor = &H00C0C0C0&
Caption = $"Form1.frx":0000
Height = 495
Index = 0
Left = 360
TabIndex = 19
Top = 1800
Width = 8535
End
Begin VB.Label Label7
Caption = "接收内容"
Height = 375
Left = 600
TabIndex = 16
Top = 360
Width = 975
End
End
Begin VB.Frame Frame2
Caption = "发送短信测试"
Height = 2415
Left = 0
TabIndex = 9
Top = 3000
Width = 10455
Begin VB.CheckBox sendstate
Caption = "状态报告"
Height = 375
Left = 9120
TabIndex = 25
Top = 720
Value = 1 'Checked
Width = 1215
End
Begin VB.CommandButton Command3
Caption = "发送短信"
Height = 375
Left = 9120
TabIndex = 15
Top = 240
Width = 1095
End
Begin VB.TextBox fsnr
Height = 1095
Left = 1560
MultiLine = -1 'True
ScrollBars = 2 'Vertical
TabIndex = 14
Text = "Form1.frx":0093
Top = 720
Width = 7335
End
Begin VB.TextBox jshm
Height = 375
Left = 1560
TabIndex = 13
Top = 240
Width = 7335
End
Begin VB.Label Label8
BackColor = &H00C0C0C0&
Caption = "*小灵通格式:本地:106+区号+号码;外地:106+0+区号+号码"
Height = 255
Index = 1
Left = 360
TabIndex = 20
Top = 2040
Width = 8535
End
Begin VB.Label Label6
Caption = "发送内容"
Height = 375
Left = 600
TabIndex = 12
Top = 720
Width = 855
End
Begin VB.Label Label5
Caption = "接收号码"
Height = 255
Left = 600
TabIndex = 11
Top = 360
Width = 855
End
End
Begin VB.Frame Frame1
Caption = "系统信息"
Height = 2895
Left = 0
TabIndex = 0
Top = 0
Width = 10455
Begin VB.TextBox Text1
Appearance = 0 'Flat
BackColor = &H00C0C000&
BorderStyle = 0 'None
Height = 375
Left = 360
TabIndex = 27
Text = "*使用说明:1)通讯配置;2)输入授权码;3)连接设备;4)发送测试;5)接收测试;6)退出。"
Top = 2400
Width = 8535
End
Begin VB.CommandButton Command1
Caption = "连接设备"
Height = 375
Left = 9120
TabIndex = 26
Top = 2400
Width = 1095
End
Begin VB.CommandButton Command2
Caption = "错误信息"
Height = 375
Left = 360
TabIndex = 8
Top = 1440
Width = 1095
End
Begin VB.TextBox cwxx
Height = 855
Left = 1560
MultiLine = -1 'True
ScrollBars = 3 'Both
TabIndex = 7
Top = 1320
Width = 8655
End
Begin VB.TextBox sqhm
Height = 375
Left = 1560
TabIndex = 6
Text = "ERTI-BVDI-PDEW-VIWX"
Top = 840
Width = 4935
End
Begin VB.TextBox Baud
Height = 375
Left = 5160
TabIndex = 4
Text = "9600"
Top = 360
Width = 1335
End
Begin VB.TextBox Device
Height = 375
Left = 2040
TabIndex = 2
Text = "COM1"
Top = 360
Width = 975
End
Begin VB.Label Label9
Caption = "通讯配置"
Height = 255
Left = 600
TabIndex = 22
Top = 480
Width = 855
End
Begin VB.Label Label8
BackColor = &H00C0C0C0&
Caption = "*授权号码由厂家提供,在产品上或包装盒中可以找到。"
Height = 855
Index = 4
Left = 6720
TabIndex = 21
Top = 360
Width = 3495
End
Begin VB.Label Label4
Caption = "输入授权号码"
Height = 375
Left = 120
TabIndex = 5
Top = 840
Width = 1215
End
Begin VB.Label Label3
Caption = "波特率"
Height = 255
Left = 4560
TabIndex = 3
Top = 480
Width = 615
End
Begin VB.Label Label2
Caption = "端口"
Height = 255
Left = 1560
TabIndex = 1
Top = 480
Width = 615
End
End
Begin VB.Label Label10
Caption = "状态信息"
Height = 255
Left = 600
TabIndex = 24
Top = 8280
Width = 855
End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Private Declare Sub GSMModemRelease Lib "GSMMultiPort.dll" (ByVal Device As String)
Private Declare Function GSMModemIsConn Lib "GSMMultiPort.dll" (ByVal Device As String) As Boolean
Private Declare Function GSMModemAutoTest Lib "GSMMultiPort.dll" Alias "GSMModemAutoTestVB6" () As String
Private Declare Function GSMModemGetErrorMsg Lib "GSMMultiPort.dll" Alias "GSMModemGetErrorMsgVB6" (ByVal Device As String) As String
Private Declare Function GSMModemGetSnInfo Lib "GSMMultiPort.dll" Alias "GSMModemGetSnInfoVB6" (ByVal Device As String, ByVal baudrate As String) As String
Private Declare Function GSMModemInit Lib "GSMMultiPort.dll" (ByVal Device As String, ByVal baudrate As String, ByVal initstring As String, ByVal charset As String, ByVal swHandshake As Boolean, ByVal sn As String) As Boolean
Private Declare Function GSMModemSMSsend Lib "GSMMultiPort.dll" (ByVal Device As String, ByVal serviceCenterAddress As String, ByVal encodeval As Integer, ByVal text As String, ByVal textlen As Integer, ByVal phonenumber As String, ByVal requestStatusReport As Boolean) As Boolean
Private Declare Function GSMModemSMSReadAll Lib "GSMMultiPort.dll" Alias "GSMModemSMSReadAllVB6" (ByVal Device As String, ByVal RD_opt As Integer) As String
'连接设备
Private Sub Command1_Click()
'1) 格式检查
If Device.text = "" Then
MsgBox "请指定通讯端口!"
Device.SetFocus
Exit Sub
End If
If Baud.text = "" Then
MsgBox "请指定通讯波特率!"
Baud.SetFocus
Exit Sub
End If
If sqhm.text = "" Then
MsgBox "请输入授权号码!"
sqhm.SetFocus
Exit Sub
End If
'2) 连接设备
status1.text = "正在连接通讯设备,请稍等 ......"
ret = GSMModemInit(Device.text, Baud.text, "E0", "GSM", False, sqhm.text)
If ret Then
MsgBox "GSMModemInit: 连接成功!"
Else
MsgBox "GSMModemInit: 连接失败!" + GSMModemGetErrorMsg(Device.text)
Exit Sub
End If
'3) 显示信息
cwxx.text = GSMModemGetErrorMsg(Device.text)
status1.text = "连接完毕!"
End Sub
'显示错误信息
Private Sub Command2_Click()
cwxx.text = GSMModemGetErrorMsg(Device.text)
End Sub
'发送短信
Private Sub Command3_Click()
Dim smscontent As String
Dim number As String
Dim smslen As Long
Dim charset As String
Dim ret, statereq As Boolean
'0) 格式检查
If jshm.text = "" Then
MsgBox "手机号码不能为空!"
jshm.SetFocus
Exit Sub
End If
If fsnr.text = "" Then
MsgBox "短信内容不能为空!"
fsnr.SetFocus
Exit Sub
End If
If sendstate.Value = 1 Then
statereq = True
Else
statereq = False
End If
'2) 发送短信
status1.text = "正在发送短信,请稍等 ......"
smscontent = StrConv(fsnr.text, vbFormUnicode)
smslen = LenB(StrConv(fsnr.text, vbFormUnicode))
number = jshm.text
ret = GSMModemSMSsend(Device.text, "", 8, smscontent, smslen, jshm.text, statereq)
If ret Then
MsgBox "GSMModemSMSsend: 短信发送成功!"
Else
MsgBox "GSMModemSMSsend: 短信发送失败!" + GSMModemGetErrorMsg(Device.text)
End If
'3) 显示信息
cwxx.text = GSMModemGetErrorMsg(Device.text)
status1.text = "发送短信完毕!."
End Sub
'接收短信
Private Sub Command4_Click()
Dim ret As Boolean
'1)接收短信
status1.text = "正在接收短信,请稍等 ......"
jsnr.text = GSMModemSMSReadAll(Device.text, 0)
If jsnr.text = "" Then
jsnr.text = "无短信!"
End If
'2)显示信息
cwxx.text = GSMModemGetErrorMsg(Device.text)
status1.text = "接收短信完毕!"
End Sub
'退出
Private Sub Command5_Click()
End
End Sub
'卸载窗体的时候
Private Sub Form_Unload(Cancel As Integer)
If GSMModemIsConn(Device.text) Then
GSMModemRelease (Device.text)
End If
End Sub
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -