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

📄 form1.frm

📁 CMPP2.0 接口的VB 程序
💻 FRM
字号:
VERSION 5.00
Begin VB.Form Form1 
   Caption         =   "MT长连接测试:"
   ClientHeight    =   4515
   ClientLeft      =   60
   ClientTop       =   450
   ClientWidth     =   5685
   LinkTopic       =   "Form1"
   ScaleHeight     =   4515
   ScaleWidth      =   5685
   StartUpPosition =   2  '屏幕中心
   Begin VB.CommandButton Command8 
      Caption         =   "关闭"
      Height          =   375
      Left            =   3480
      TabIndex        =   11
      Top             =   3840
      Width           =   1815
   End
   Begin VB.CommandButton Command7 
      Caption         =   "CMPP_GET_MO"
      Height          =   375
      Left            =   3480
      TabIndex        =   10
      Top             =   3120
      Width           =   1815
   End
   Begin VB.CommandButton Command6 
      Caption         =   "CMPP_CONNECT_MO"
      Height          =   375
      Left            =   1560
      TabIndex        =   9
      Top             =   3120
      Width           =   1815
   End
   Begin VB.CommandButton Command5 
      Caption         =   "CMPP_DISCONNECT"
      Height          =   375
      Left            =   3600
      TabIndex        =   8
      Top             =   840
      Width           =   1815
   End
   Begin VB.CommandButton Command4 
      Caption         =   "CMPP_CANCEL"
      Height          =   375
      Left            =   1920
      TabIndex        =   7
      Top             =   840
      Width           =   1455
   End
   Begin VB.CommandButton Command3 
      Caption         =   "CMPP_QUERY"
      Height          =   375
      Left            =   240
      TabIndex        =   6
      Top             =   840
      Width           =   1455
   End
   Begin VB.CommandButton Command2 
      Caption         =   "CMPP_SUBMIT"
      Height          =   375
      Left            =   3600
      TabIndex        =   5
      Top             =   240
      Width           =   1815
   End
   Begin VB.CommandButton Command1 
      Caption         =   "CMPP_CONNECT"
      Height          =   375
      Left            =   1920
      TabIndex        =   4
      Top             =   240
      Width           =   1455
   End
   Begin VB.CommandButton BRIEF_SUBMIT 
      Caption         =   "BRIEF_SUBMIT"
      Height          =   375
      Left            =   1560
      TabIndex        =   0
      Top             =   2520
      Width           =   1815
   End
   Begin VB.Label Label3 
      Caption         =   "MT长连接测试:"
      Height          =   255
      Left            =   120
      TabIndex        =   3
      Top             =   240
      Width           =   1215
   End
   Begin VB.Label Label2 
      Caption         =   "MO测试:"
      Height          =   255
      Left            =   120
      TabIndex        =   2
      Top             =   3240
      Width           =   975
   End
   Begin VB.Label Label1 
      Caption         =   "短连接测试:"
      Height          =   255
      Left            =   120
      TabIndex        =   1
      Top             =   2640
      Width           =   1215
   End
End
Attribute VB_Name = "Form1"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False






Private Sub BRIEF_SUBMIT_Click()

Dim gw_ip As String
Dim Port As Integer
Dim passwd As String
Dim msg_id As Msgid
Dim msg_level As Integer
Dim service_id As String
Dim msg_format As Integer
Dim msg_src As String
Dim fee_type As String
Dim fee_code As String
Dim valid_time As String
Dim at_time As String
Dim tp_pid As Integer
Dim udhi As Integer
Dim fee_user_type As Integer
Dim charge_mobile As String
Dim src_mobile As String
Dim user_num As Integer
Dim dest_mobiles As String
Dim msg As String
Dim msg_len As Integer
Dim need_response As Integer
Dim result As Integer

gw_ip = "127.0.0.1"
Port = 7890
username = "901234"
passwd = "1234"

msg_level = 3
service_id = "HELP"
msg_format = 15
msg_src = "901234"
fee_type = "01"
fee_code = "000000"
valid_time = "0"
at_time = "0"
tp_pid = 0
udhi = 0
fee_user_type = 0
charge_mobile = "13801234567"
src_mobile = "13801234567"
user_num = 1
dest_mobiles = "13801234567"
msg = "CMPPBriefSubmit测试!"
msg_len = LenB(StrConv(msg, vbFromUnicode))
need_response = 0
Dim cmpp As CMPP2
Set cmpp = New CMPP2



cmpp.BRIEF_SUBMIT gw_ip, _
                    Port, _
                    username, _
                    passwd, _
                    VarPtr(msg_id), _
                    msg_level, _
                    service_id, _
                    msg_format, _
                    msg_src, _
                    fee_type, _
                    fee_code, _
                    valid_time, _
                    at_time, _
                    tp_pid, _
                    udhi, _
                    fee_user_type, _
                    charge_mobile, _
                    src_mobile, _
                    user_num, _
                    dest_mobiles, _
                    msg, _
                    msg_len, _
                    need_response

MsgBox "  msg_id :" & msg_id.msg_id(0) & msg_id.msg_id(1) & msg_id.msg_id(2) & msg_id.msg_id(3) & msg_id.msg_id(4) & msg_id.msg_id(5) & msg_id.msg_id(6) & msg_id.msg_id(7)
End Sub

Private Sub Command1_Click()
Dim ret As Integer
    gwconnid = mycmpp.Connect("127.0.0.1", 7890, "901234", "1234")
    'MsgBox "gwconnid:" & gwconnid
End Sub

Private Sub Command2_Click()
Dim gw_ip As String
Dim Port As Integer
Dim passwd As String
Dim msg_id As Msgid
Dim msg_level As Integer
Dim service_id As String
Dim msg_format As Integer
Dim msg_src As String
Dim fee_type As String
Dim fee_code As String
Dim valid_time As String
Dim at_time As String
Dim tp_pid As Integer
Dim udhi As Integer
Dim fee_user_type As Integer
Dim charge_mobile As String
Dim src_mobile As String
Dim user_num As Integer
Dim dest_mobiles As String
Dim msg As String
Dim msg_len As Integer
Dim need_response As Integer
Dim result As Integer

gw_ip = "127.0.0.1"
Port = 7890
username = "1234"
passwd = "1234"

msg_level = 3
service_id = "HELP"
msg_format = 15
msg_src = "901234"
fee_type = "01"
fee_code = "000000"
valid_time = "0"
at_time = "0"
tp_pid = 0
udhi = 0
fee_user_type = 0
charge_mobile = "13801234567"
src_mobile = "13801234567"
user_num = 1
dest_mobiles = "13801234567"
msg = "CMPPSubmit测试!"
msg_len = 19
need_response = 0
MsgBox "gwconnid:" & gwconnid
If gwconnid > -1 Then
    result = mycmpp.Submit(gwconnid, _
                        VarPtr(msg_id), _
                        msg_level, _
                        service_id, _
                        msg_format, _
                        msg_src, _
                        fee_type, _
                        fee_code, _
                        valid_time, _
                        at_time, _
                        tp_pid, _
                        udhi, _
                        fee_user_type, _
                        charge_mobile, _
                        src_mobile, _
                        user_num, _
                        dest_mobiles, _
                        msg, _
                        msg_len, _
                        need_response)
    MsgBox "  msg_id :" & msg_id.msg_id(0) & msg_id.msg_id(1) & msg_id.msg_id(2) & msg_id.msg_id(3) & msg_id.msg_id(4) & msg_id.msg_id(5) & msg_id.msg_id(6) & msg_id.msg_id(7)
End If
End Sub

Private Sub Command3_Click()
    Dim qres As QueryRes
    Dim ret As Integer
    ret = mycmpp.Query(gwconnid, "20010219", 10, "FUNC", VarPtr(qres))
    If ret > -1 Then
        MsgBox qres.mt_total_msg(0) & qres.mt_total_msg(1) & qres.mt_total_msg(2) & qres.mt_total_msg(3)
    End If
End Sub

Private Sub Command4_Click()
    Dim ret As Integer
    Dim mgs_id As Msgid
    Dim cancelrep As CancelRep_Msg
    ret = mycmpp.Cancel(gwconnid, VarPtr(Msgid), VarPtr(cancelrep))
    If (ret > -1) Then
        MsgBox "Cancel OK"
    End If
End Sub

Private Sub Command5_Click()
    Dim ret As Integer
    ret = mycmpp.Disconnect(gwconnid)

    ret = mycmpp.Disconnect(moconnid)
End Sub

Private Sub Command6_Click()
    moconnid = mycmpp.Connect_MO("127.0.0.1", 7890, "901234", "1234")
    If moconnid > -1 Then
        MsgBox moconnid
    End If
    
End Sub

Public Sub Command7_Click()
Dim mo As MOmsg
Dim byteAry() As Byte
Dim byteAry1() As Byte
Dim byteAry2() As Byte
Dim byteAry3() As Byte
Dim ret As Integer

'mo.msgID = 0
byteAry = StrConv("13983752390", vbFromUnicode)
For i = LBound(byteAry) To UBound(byteAry)
    mo.dest_id(i) = byteAry(i)
Next i


byteAry1 = StrConv("5757", vbFromUnicode)
For i = LBound(byteAry1) To UBound(byteAry1)
    mo.service_id(i) = byteAry1(i)
Next i

byteAry2 = StrConv("13983752390", vbFromUnicode)
For i = LBound(byteAry2) To UBound(byteAry2)
    mo.sourceUser(i) = byteAry2(i)
Next i

byteAry3 = StrConv("test", vbFromUnicode)
For i = LBound(byteAry3) To UBound(byteAry3)
    mo.msg(i) = byteAry3(i)
Next i
mo.msgLen = i
mo.msgFormat = 15
mo.reg_deliver = 1
mo.tp_pid = 1
mo.tp_udhi = 1


ret = mycmpp.Get_MO(moconnid, VarPtr(mo))
If (ret > -1) Then
    If (mycmpp.Is_Status_Report(VarPtr(mo)) > 0) Then
        MsgBox "Is_Status_Report"
    Else
        MsgBox StrConv(mo.msg, vbUnicode)
        MsgBox "get MOMSG OK"
    End If
End If



End Sub

Private Sub Command8_Click()

    If gwconnid > -1 Then
        Command5_Click

    End If

    End
End Sub



Private Sub Form_Load()
    Set mycmpp = New cmppatlLib.CMPP2

End Sub

Private Sub Form_Unload(Cancel As Integer)
    Set mycmpp = Nothing
End Sub

⌨️ 快捷键说明

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