VB控制COM口短信收发
百度有字数限制,连源代码的一个类都粘不上,下面这个类是发送接收短信的类的一部分,这个类总共有一千二百多行,根本粘不全,你可以参考一下。
短信终端操作的关键是短信的编码和解码,英文资料很多,中文的基本找不到,你可以多查些资料。
Option Explicit OnPublic Class Jwc '_______________声明mscomm控件__________________ Public MSComm1 As New MSCommLib.MSComm '__________________串口调试_____________________ Dim bug As String Public B_bug As Boolean = False '__________________串口设置_____________________ Public L_com(256) As String Public I_P As Integer = 1 '端口号 Public S_Set As String = "9600,n,8,1" '初始字符串 Public C_open As Boolean = False Public ret_l As Double '__________________短信共用变量_________________ Dim l_msg_c As Integer = 0 Dim l_msg_i As Integer = 0 Dim l_msg_t As Integer = 0 Dim l_msg_x As Integer = 16 '__________________读取短信_____________________ Public ID1 As String '短信编号 Public ID2 As String '短信分类 Public n1 As Integer '短信中心号码长度 Public n2 As Integer '被叫号码长度 Public n3 As Integer '用户数据长度 Public n4 As Integer '日期长度 Public np1 As String '短信中心号码 Public np2 As String '被叫号码 Public da1 As String '日期 Public sp1 As String '用户数据 Public Cont As Integer '短信个数 Public scod As String '编码方式 Dim ms(1000, 10) '_______________发送短信________________________ Public s_mg As String Public m_succ As Boolean '短信发送状态 Public cs1 As String = "0891" Public cs2 As String = "11000D91" Public cs3 As String = "000800" Public Lms As Integer '_______________接收短信________________________ Public mg_count As Integer = 0 Public mg_ade(1000) As Integer Public mg_N As Boolean = False '_______________读取联系人______________________ Dim Pbook(1000, 2) As String Public bookcont As Integer '_______________打开设备________________________ Public Function PhoOpen() As Boolean Dim i As Integer Dim j As Integer Dim n As Integer Dim coms(256) As Integer PhoOpen = False If C_open Then PhoOpen = True Exit Function End If For i = 0 To 255 L_com(i) = "" Next j = 0 For i = 1 To 64 If CheckCom(i) Then L_com(j) = i 'MsgBox(j & " " & i) j = j + 1 End If Next i '触发OnComm事件的字符长度 For i = 0 To j - 1 n = L_com(i) 'MsgBox(i & " " & n) I_P = n '记录当前端口号 If CheckModem(n) Then 'MsgBox("连接成功!") PhoOpen = True C_open = True PhoLoading() Exit For End If Next i End Function '_______________发送AT指令______________________ Public Function ATcode(ByVal s As String) As String If Not C_open Then Call PhoOpen() If Not C_open Then 'MsgBox("未发现设备!", vbInformation) ATcode = "未发现设备!" Exit Function End If End If ATcode = "" MSComm1.Output = s Dim i As Integer Dim t As String Dim Sall As String = "" For i = 0 To 1000 System.Threading.Thread.Sleep(10) t = MSComm1.Input While Len(t) > 0 Sall = Sall & t t = "" i = 0 End While If ATend(Sall) Then Exit For End If If i >= 1000 Then Me.C_open = False PhoClose() End If Next ret_l = Len(Sall) 'If ret_l = 0 Then ' Sall = "连接超时!" 'End If CheckNewMsg(Sall) ATcode = Sall End Function Public Function ATend(ByVal s As String) As Boolean Dim i As Integer Dim t As String = "" Dim Sall As String = "" For i = 1 To Len(s) t = Mid(s, i, 1) If t Chr(13) And t Chr(10) And t Chr(32) Then Sall = Sall + t End If Next ATend = False m_succ = False If Right(Sall, 1) = ">" Then ATend = True m_succ = True Exit Function End If If Right(Sall, 2) = "OK" Then ATend = True m_succ = True Exit Function End If If Right(Sall, 5) = "ERROR" Then ATend = True Exit Function End If If Right(Sall, 7) = "CARRIER" Then ATend = True Exit Function End If End Function '_______________读取短信________________________ Function Getmsg(ByVal i As Integer, ByVal j As Integer) As String Getmsg = "" Try Getmsg = ms(i, j) Catch ex As Exception End Try End Function '_____________发送短信_________________________ Function SMG(ByVal n1 As String, ByVal n2 As String, ByVal s1 As String) As Boolean Dim l1 As String Dim l2 As String Dim l3 As String '十六进制长度 Dim ln1 As String Dim ln2 As String Dim ln3 As String '十进制长度 Dim t1, t2, t3 As String Dim mg As String Dim m(255) As String Dim m_l(255) As String Dim m_c As Integer Dim ms1, ms2 As String Dim i As Integer = 0 t1 = "" t2 = "" t3 = "" ms1 = "" ms2 = "" '_________处理短信中心号码__________ t1 ...
vb中用mscomm 做短信收发,发送的短信没法显示中文
如果你是中国移动的卡 可以使用移动的飞信业务 开通飞信没有任何费用 使用飞信电脑客户端在电脑上给另一个移动用户发送短信不花钱 但是必须满足两个方面 一个是对方必须也是移动客户,二是 对方必须也开通飞信业务并且你要加对方飞信好友 用手机使用飞信软件发送信息消费的是上网的流量,你可以去开通个gprs套餐,也不再花费其他费用 对方手机没有安装飞信软件也可以收到信息 但是对方必须开通飞信业务并且是你的飞信好友
用VB怎么做出像手机那样能打电话、发短信的功能
Declare Function FindWindowExA Lib "user32" (ByVal Hwnd1 As Long, ByVal Hwnd2 As Long, _ByVal lpsz1 As String, ByVal lpsz2 As String) As LongDeclare Function SendMessageA Lib "user32" (ByVal Hwnd As Long, ByVal wMsg As Long, _ByVal wParam As Long, lParam As Any) As LongDeclare Function GetWindowTextA Lib "user32" (ByVal Hwnd As Long, ByVal lpString As String, _ByVal cch As Long) As LongConst EM_REPLACESEL = &HC2Const BM_CLICK = &HF5Sub Test()Dim Hwnd As LongDim Title As StringHwnd = FindWindowExA(0, 0, "#32770", vbNullString)Do While Hwnd > 0Hwnd = FindWindowExA(0&, Hwnd, "#32770", vbNullString)Title = Space(255)GetWindowTextA Hwnd, Title, 256If (Title Like "*聊天中*") Or (Title Like "*群*") Or (Title Like "*会话中*") ThenSendMsg Hwnd, "QQ消息群发"End IfLoopEnd SubFunction SendMsg(Hwnd As Long, Meg As String)Dim Hwnd1 As LongDim Hwnd2 As LongHwnd1 = FindWindowExA(Hwnd, 0, "#32770", vbNullString)Hwnd2 = FindWindowExA(Hwnd1, 0, "Button", "发送(S)")Hwnd1 = FindWindowExA(Hwnd1, Hwnd2, "AfxWnd42", vbNullString)Hwnd1 = FindWindowExA(Hwnd1, 0, "RichEdit", vbNullString)SendMessageA Hwnd1, EM_REPLACESEL, 0, ByVal MegSendMessageA Hwnd2, BM_CLICK, 0, ByVal 0End Function
有没有用流量发短信的软件?求推荐。
推荐使用“云号码”,你下载使用云号码之后,每月有200条免费短信赠送,你可以给任意好友发送还不扣你话费,无论接收短信的对方是联通、移动、电信用户均可接收。
无需对方安装云号码哦。
如果每月200条免费短信,你还嫌不够用的话,你可以让常联系的朋友也安装云号码,双方直接发送Free信走流量也很便宜哦! 《赠人玫瑰手有余香,祝您好运一生一世,如果回答有用,请点“好评”,谢谢^_^!》
污污污污污污