⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 form1.frm

📁 短信猫在VB平台上开发的源代码
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "Form1"
   ClientHeight    =   8595
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   10590
   LinkTopic       =   "Form1"
   ScaleHeight     =   8595
   ScaleWidth      =   10590
   StartUpPosition =   3  '窗口缺省
   Begin VB.Frame Frame3 
      Caption         =   "接收短信测试"
      Height          =   2535
      Left            =   120
      TabIndex        =   13
      Top             =   6000
      Width           =   10335
      Begin VB.CommandButton Command4 
         Caption         =   "接收短信"
         Height          =   375
         Left            =   9000
         TabIndex        =   21
         Top             =   480
         Width           =   1095
      End
      Begin VB.TextBox jsnr 
         Height          =   1575
         Left            =   1560
         MultiLine       =   -1  'True
         ScrollBars      =   3  'Both
         TabIndex        =   20
         Top             =   480
         Width           =   7095
      End
      Begin VB.Label Label8 
         BackColor       =   &H80000018&
         Caption         =   "*接收短信息返回字符串格式为:手机号码|短信内容||手机号码|短信内容||"
         Height          =   255
         Index           =   0
         Left            =   720
         TabIndex        =   22
         Top             =   2160
         Width           =   7935
      End
      Begin VB.Label Label7 
         Caption         =   "接收内容"
         Height          =   375
         Left            =   600
         TabIndex        =   19
         Top             =   480
         Width           =   975
      End
   End
   Begin VB.Frame Frame2 
      Caption         =   "发送短信测试"
      Height          =   2415
      Left            =   120
      TabIndex        =   12
      Top             =   3480
      Width           =   10335
      Begin VB.CommandButton Command3 
         Caption         =   "发送短信"
         Height          =   375
         Left            =   9000
         TabIndex        =   18
         Top             =   240
         Width           =   1095
      End
      Begin VB.TextBox fsnr 
         Height          =   1095
         Left            =   1560
         MultiLine       =   -1  'True
         ScrollBars      =   3  'Both
         TabIndex        =   17
         Top             =   840
         Width           =   7095
      End
      Begin VB.TextBox jshm 
         Height          =   375
         Left            =   1560
         TabIndex        =   16
         Top             =   240
         Width           =   7095
      End
      Begin VB.Label Label8 
         BackColor       =   &H80000018&
         Caption         =   "*小灵通格式:本地:106+区号+号码;外地:106+0+区号+号码"
         Height          =   255
         Index           =   1
         Left            =   600
         TabIndex        =   23
         Top             =   2040
         Width           =   8055
      End
      Begin VB.Label Label6 
         Caption         =   "发送内容"
         Height          =   375
         Left            =   600
         TabIndex        =   15
         Top             =   720
         Width           =   855
      End
      Begin VB.Label Label5 
         Caption         =   "接收号码"
         Height          =   255
         Left            =   600
         TabIndex        =   14
         Top             =   360
         Width           =   855
      End
   End
   Begin VB.Frame Frame1 
      Caption         =   "系统信息"
      Height          =   2775
      Left            =   120
      TabIndex        =   0
      Top             =   600
      Width           =   10335
      Begin VB.CommandButton Command2 
         Caption         =   "错误信息"
         Height          =   375
         Left            =   360
         TabIndex        =   11
         Top             =   1800
         Width           =   1095
      End
      Begin VB.TextBox cwxx 
         Height          =   855
         Left            =   1560
         MultiLine       =   -1  'True
         ScrollBars      =   3  'Both
         TabIndex        =   10
         Top             =   1800
         Width           =   7095
      End
      Begin VB.TextBox sqhm 
         Height          =   375
         Left            =   1560
         TabIndex        =   9
         Text            =   "RIWT-DGFI-CFWW-GIWQ"
         Top             =   1320
         Width           =   4935
      End
      Begin VB.CommandButton Command1 
         Caption         =   "机器号码"
         Height          =   375
         Left            =   360
         TabIndex        =   7
         Top             =   840
         Width           =   1095
      End
      Begin VB.TextBox jqhm 
         Height          =   375
         Left            =   1560
         TabIndex        =   6
         Top             =   840
         Width           =   4935
      End
      Begin VB.TextBox Baud 
         Height          =   375
         Left            =   4800
         TabIndex        =   5
         Top             =   360
         Width           =   1695
      End
      Begin VB.TextBox Device 
         Height          =   375
         Left            =   2040
         TabIndex        =   3
         Top             =   360
         Width           =   1815
      End
      Begin VB.Label Label8 
         BackColor       =   &H80000018&
         Caption         =   "*由厂商根据机器号码产生出来的。"
         Height          =   255
         Index           =   4
         Left            =   6600
         TabIndex        =   26
         Top             =   1440
         Width           =   3375
      End
      Begin VB.Label Label8 
         BackColor       =   &H80000018&
         Caption         =   "*请将此机器号码发送给厂商。"
         Height          =   255
         Index           =   3
         Left            =   6600
         TabIndex        =   25
         Top             =   960
         Width           =   3375
      End
      Begin VB.Label Label8 
         BackColor       =   &H80000018&
         Caption         =   "*若不指定系统会自动进行检测。"
         Height          =   255
         Index           =   2
         Left            =   6600
         TabIndex        =   24
         Top             =   480
         Width           =   3375
      End
      Begin VB.Label Label4 
         Caption         =   "授权号码"
         Height          =   375
         Left            =   600
         TabIndex        =   8
         Top             =   1440
         Width           =   735
      End
      Begin VB.Label Label3 
         Caption         =   "波特率"
         Height          =   255
         Left            =   4200
         TabIndex        =   4
         Top             =   480
         Width           =   615
      End
      Begin VB.Label Label2 
         Caption         =   "端口"
         Height          =   255
         Left            =   1560
         TabIndex        =   2
         Top             =   480
         Width           =   615
      End
   End
   Begin VB.Label Label1 
      Alignment       =   2  'Center
      BackColor       =   &H00808000&
      Caption         =   "短信接口VB6测试"
      BeginProperty Font 
         Name            =   "隶书"
         Size            =   18
         Charset         =   134
         Weight          =   400
         Underline       =   0   'False
         Italic          =   0   'False
         Strikethrough   =   0   'False
      EndProperty
      ForeColor       =   &H8000000E&
      Height          =   495
      Left            =   120
      TabIndex        =   1
      Top             =   0
      Width           =   10335
   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 "dllforvc.dll" ()
Private Declare Function getTestString Lib "testVBDll.dll" () As Byte()
Private Declare Function GSMModemIsConn Lib "dllforvc.dll" () As Boolean
Private Declare Function GSMModemGetErrorMsg Lib "dllforvc.dll" () As String
Private Declare Function GSMModemGetDevice Lib "dllforvc.dll" () As String
Private Declare Function GSMModemGetBaudrate Lib "dllforvc.dll" () As String
Private Declare Function GSMModemGetSnInfoNew Lib "dllforvc.dll" (ByVal Device As String, ByVal baudrate As String) As String
Private Declare Function GSMModemInitNew Lib "dllforvc.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 "dllforvc.dll" (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 "dllforvc.dll" (ByVal RD_opt As Integer) As String

Private Sub Command1_Click()
        jqhm.text = GSMModemGetSnInfoNew(Device.text, Baud.text)
        Device.text = GSMModemGetDevice()
        Baud.text = GSMModemGetBaudrate()
        cwxx.text = GSMModemGetErrorMsg()
End Sub

Private Sub Command3_Click()
        Dim smscontent As String
        Dim number As String
        Dim smslen As Long
        Dim charset As String
        Dim ret As Boolean
             
        '0) 格式检查
        If jshm.text = "" Then
            MsgBox "手机号码不能为空!"
            jshm.SetFocus
            Exit Sub
        End If
        smslen = Len(jshm.text)
        'If smslen <> 11 Then
        '    MsgBox "手机号码长度不对!"
        '    jshm.SetFocus
        '    Exit Sub
        'End If
        If fsnr.text = "" Then
            MsgBox "短信内容不能为空!"
            fsnr.SetFocus
            Exit Sub
        End If

        '1)连接设备
        ret = GSMModemInitNew(Device.text, Baud.text, "", "GSM", False, sqhm.text)
        
        If ret Then
            MsgBox "GSMModemInit: 连接成功!"
        Else
            MsgBox "GSMModemInit: 连接失败!" + GSMModemGetErrorMsg()
            Exit Sub
        End If
        cwxx.text = GSMModemGetErrorMsg()
        Device.text = GSMModemGetDevice()
        Baud.text = GSMModemGetBaudrate()

        '2) 发送短信
        smscontent = fsnr.text
        'smslen = Len(fsnr.text)
        smslen = LenB(StrConv(fsnr.text, vbFormUnicode))
        number = jshm.text
        ret = GSMModemSMSsend("", 8, fsnr.text, smslen, jshm.text, False)
        If ret Then
            MsgBox "GSMModemSMSsend: 短信发送成功!"
        Else
            MsgBox "GSMModemSMSsend: 短信发送失败!" + GSMModemGetErrorMsg()
        End If
        cwxx.text = GSMModemGetErrorMsg()
        
        '3) 显示错误信息
        cwxx.text = GSMModemGetErrorMsg()
        
        '4) 释放资源
        GSMModemRelease

End Sub

Private Sub Command4_Click()
        
         Dim ret As Boolean
         
        ret = GSMModemInitNew(Device.text, Baud.text, "", "GSM", False, sqhm.text)
        '1)连接设备
        If ret Then
            MsgBox ("GSMModemInit: 连接成功!")
        Else
            MsgBox ("GSMModemInit: 连接失败!" + GSMModemGetErrorMsg())
            Exit Sub
        End If
        
        cwxx.text = GSMModemGetErrorMsg()
        Device.text = GSMModemGetDevice()
        Baud.text = GSMModemGetBaudrate()

        '2)接收短信
        jsnr.text = GSMModemSMSReadAll(0)
        cwxx.text = GSMModemGetErrorMsg()
        
        If jsnr.text = "" Then
           jsnr.text = "无短信息!"
        End If
        
        '4) 释放资源
        GSMModemRelease
        cwxx.text = GSMModemGetErrorMsg()
        
End Sub

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -