📄 form1.vb
字号:
Imports System
Imports System.Threading
Imports System.Text
Imports System.Runtime.InteropServices
Public Class Form1
Inherits System.Windows.Forms.Form
Public Declare Auto Function SsmSetEvent Lib "SHP_A3.dll" (ByVal wEvent As Int32, ByVal nReference As Int32, ByVal bEnable As Boolean, ByRef pEventSet As EVENT_SET_INFO) As Int32
Public Declare Function SsmWaitForEventA Lib "SHP_A3.dll" (ByVal dwTimeOut As Int32, ByRef pEvent As SSM_EVENT) As Int32
'define const
'===================================================
'Channel state
Public Const CH_IDLE = 0 'Idle state
Public Const CH_RING = 1 'Ringing state
Public Const CH_ACTIVE = 2 'Active state
Public Const CH_OFFLINE = 3 'Outline state
Public Const CH_WAITFOR_ONHOOK = 4 'Far end has been on hook ,waiting for near end on hook;
'====================================================
'===================================================
'Listen state
Public Const UNLISTEN = 5 'UNLISTEN
Public Const LISTEN = 6 'Listen
'===================================================
'===================================================
'Record state
Public Const UNRECORD = 7 'Unrecord
Public Const RECORD = 8 'Record
'===================================================
'===================================================
'call dir
Public Const UNKNOWN = 9 'UNKNOWN
Public Const UP = 10 'Call out
Public Const DOWN = 11 'Call in
'===================================================
Public Const MAX_CALLID_LEN = 50
Public Const MAX_LCD_LEN = 300
Public Const MAX_ERRMSG_LEN = 300
Public Const E_CHG_ChState = &H18
Public Const E_RCV_DSTDChannel = &H41
Public Const DST_OFFHOOK = &H8
Public Const DST_RING_ON = &H101F
Public Const DST_MSG_CHG = &H1008
Public Const DST_RING_OFF = &H1020
Public Const DST_ONHOOK = &HE
Public Const DST_ABANDONED = &H103A
Public Const MAX_BUFFERLEN = 300
Public Enum TRUNK_STATUS
S_CALL_STANDBY = 0
S_CALL_PICKUPED = 1
S_CALL_RINGING = 2
S_CALL_TALKING = 3
S_CALL_ANALOG_WAITDIALTONE = 4
S_CALL_ANALOG_TXPHONUM = 5
S_CALL_ANALOG_WAITDIALRESULT = 6
S_CALL_PENDING = 7
S_CALL_OFFLINE = 8
S_CALL_WAIT_REMOTE_PICKUP = 9
S_CALL_ANALOG_CLEAR = 10
S_CALL_UNAVAILABLE = 11
S_CALL_LOCKED = 12
End Enum
Public Structure EVENT_SET_INFO
Public dwWorkMode As Int32
Public lpHandlerParam As IntPtr
Public dwOutCondition As Int32
Public dwOutParamVal As Int32
Public dwUser As Int32
End Structure
Public Structure CHANNEL
Public WorkState As Int32 'Channel state
Public IsListen As Int32 'Listen state
Public IsRecord As Int32 'Record state
Public pCallId() As Byte 'Pho Num
Public LCDLen As Int32 'length of LCD information
Public CallIdLen As Int32 'length of call ID;
Public Lcd() As Byte 'LCD info
Public Dir As Int32 'Call dir
End Structure
Public Structure SSM_EVENT
Public wEventCode As Int16
Public nReference As Int32
Public dwParam As Int32
Public dwUser As Int32
Public dwSubReason As Int32 'Event sub-reason
Public dwXtraInfo As Int32 'Extra information
Public pvBuffer As IntPtr
Public dwBufferLength As Int32 'Length of buffer pointed by pvBuffer
Public dwDataLength As Int32 'Length of data in buffer pointed by pvBuffer
Public dwEventFlag As Int32 'Falgs of the following:
'bit 0, =1 - App created the event
' =0 - SHP_A3.DLL created the event
'bit 1, Reserved
'bit 2, =1 - data has been truncated
' =0 - data has not been truncated
Public dwReserved1 As Int32
Public llReserved2 As Int32
End Structure
Public nTimer As Int32
Dim ChannelState(200) As CHANNEL
Public MaxLine As Int32
Public ListenChannel As Int32
Public nRecFormat As Int32
Dim ThreadHandle As Thread
#Region " Windows 窗体设计器生成的代码 "
Public Sub New()
MyBase.New()
'该调用是 Windows 窗体设计器所必需的。
InitializeComponent()
'在 InitializeComponent() 调用之后添加任何初始化
End Sub
'窗体重写 dispose 以清理组件列表。
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
SsmCloseCti()
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub
'Windows 窗体设计器所必需的
Private components As System.ComponentModel.IContainer
'注意: 以下过程是 Windows 窗体设计器所必需的
'可以使用 Windows 窗体设计器修改此过程。
'不要使用代码编辑器修改它。
Friend WithEvents ListView1 As System.Windows.Forms.ListView
Friend WithEvents Timer1 As System.Timers.Timer
Friend WithEvents Label1 As System.Windows.Forms.Label
Friend WithEvents Label2 As System.Windows.Forms.Label
Friend WithEvents RadioButton1 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton2 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton3 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton4 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton5 As System.Windows.Forms.RadioButton
Friend WithEvents RadioButton6 As System.Windows.Forms.RadioButton
Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox
Friend WithEvents Button1 As System.Windows.Forms.Button
Friend WithEvents Button2 As System.Windows.Forms.Button
<System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()
Me.ListView1 = New System.Windows.Forms.ListView
Me.Timer1 = New System.Timers.Timer
Me.Label1 = New System.Windows.Forms.Label
Me.Label2 = New System.Windows.Forms.Label
Me.RadioButton1 = New System.Windows.Forms.RadioButton
Me.RadioButton2 = New System.Windows.Forms.RadioButton
Me.RadioButton3 = New System.Windows.Forms.RadioButton
Me.RadioButton4 = New System.Windows.Forms.RadioButton
Me.RadioButton5 = New System.Windows.Forms.RadioButton
Me.RadioButton6 = New System.Windows.Forms.RadioButton
Me.ComboBox1 = New System.Windows.Forms.ComboBox
Me.Button1 = New System.Windows.Forms.Button
Me.Button2 = New System.Windows.Forms.Button
CType(Me.Timer1, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'ListView1
'
Me.ListView1.Location = New System.Drawing.Point(32, 16)
Me.ListView1.Name = "ListView1"
Me.ListView1.Size = New System.Drawing.Size(744, 408)
Me.ListView1.TabIndex = 0
Me.ListView1.View = System.Windows.Forms.View.Details
'
'Timer1
'
Me.Timer1.Enabled = True
Me.Timer1.Interval = 1000
Me.Timer1.SynchronizingObject = Me
'
'Label1
'
Me.Label1.Location = New System.Drawing.Point(32, 452)
Me.Label1.Name = "Label1"
Me.Label1.Size = New System.Drawing.Size(136, 16)
Me.Label1.TabIndex = 1
Me.Label1.Text = "Record Coding Format:"
'
'Label2
'
Me.Label2.Location = New System.Drawing.Point(32, 480)
Me.Label2.Name = "Label2"
Me.Label2.Size = New System.Drawing.Size(136, 16)
Me.Label2.TabIndex = 1
Me.Label2.Text = "Listened Channel:"
'
'RadioButton1
'
Me.RadioButton1.Location = New System.Drawing.Point(176, 448)
Me.RadioButton1.Name = "RadioButton1"
Me.RadioButton1.Size = New System.Drawing.Size(72, 24)
Me.RadioButton1.TabIndex = 2
Me.RadioButton1.Text = "Default"
'
'RadioButton2
'
Me.RadioButton2.Location = New System.Drawing.Point(256, 448)
Me.RadioButton2.Name = "RadioButton2"
Me.RadioButton2.Size = New System.Drawing.Size(72, 24)
Me.RadioButton2.TabIndex = 2
Me.RadioButton2.Text = "A-law"
'
'RadioButton3
'
Me.RadioButton3.Location = New System.Drawing.Point(336, 448)
Me.RadioButton3.Name = "RadioButton3"
Me.RadioButton3.Size = New System.Drawing.Size(72, 24)
Me.RadioButton3.TabIndex = 2
Me.RadioButton3.Text = "u-law"
'
'RadioButton4
'
Me.RadioButton4.Location = New System.Drawing.Point(416, 448)
Me.RadioButton4.Name = "RadioButton4"
Me.RadioButton4.Size = New System.Drawing.Size(80, 24)
Me.RadioButton4.TabIndex = 2
Me.RadioButton4.Text = "IMA-ADPCM"
'
'RadioButton5
'
Me.RadioButton5.Location = New System.Drawing.Point(512, 448)
Me.RadioButton5.Name = "RadioButton5"
Me.RadioButton5.Size = New System.Drawing.Size(72, 24)
Me.RadioButton5.TabIndex = 2
Me.RadioButton5.Text = "GC8"
'
'RadioButton6
'
Me.RadioButton6.Location = New System.Drawing.Point(592, 448)
Me.RadioButton6.Name = "RadioButton6"
Me.RadioButton6.Size = New System.Drawing.Size(72, 24)
Me.RadioButton6.TabIndex = 2
Me.RadioButton6.Text = "G729A"
'
'ComboBox1
'
Me.ComboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList
Me.ComboBox1.Location = New System.Drawing.Point(176, 480)
Me.ComboBox1.Name = "ComboBox1"
Me.ComboBox1.Size = New System.Drawing.Size(88, 20)
Me.ComboBox1.TabIndex = 3
'
'Button1
'
Me.Button1.Location = New System.Drawing.Point(320, 480)
Me.Button1.Name = "Button1"
Me.Button1.Size = New System.Drawing.Size(112, 23)
Me.Button1.TabIndex = 4
Me.Button1.Text = "StartListen"
'
'Button2
'
Me.Button2.Location = New System.Drawing.Point(448, 480)
Me.Button2.Name = "Button2"
Me.Button2.Size = New System.Drawing.Size(112, 23)
Me.Button2.TabIndex = 4
Me.Button2.Text = "StopListen"
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)
Me.ClientSize = New System.Drawing.Size(800, 518)
Me.Controls.Add(Me.Button1)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -