手机号码有两种表示方法:11位和13位(带国家码86),一般手机发送时都是以13位形式表示的,所以以上的函数还有一个功能是自动将11位格式手机号码转换为13位形式,然后再转换为pdu串。
² 手机短信的发送
手机短信的发送主要借助于vb的mscomm控件实现,关于mscomm控件,前面的技术介绍部分有详细介绍。短信的发送是由at+cmgs指令完成的,采用pdu模式发送,函数代码如下:
|
const prex = "0891" const midx = "11000d91" const sufx = "000800" public function sendsms(csca as string, num as string, msg as string) as _boolean dim pdu, psmsc, pnum, pmsg as string dim leng as string dim length as integer length = len(msg) length = 2 * length leng = hex(length) if length < 16 then leng = "0" & leng psmsc = trim(telc(csca)) pnum = trim(telc(num)) pmsg = trim(ascg(msg)) pdu = prex & psmsc & midx & pnum & sufx & leng & pmsg sleep(1) mobcomm.output = "at+cmgf=0" + vbcr mobcomm.output = "at+cmgs=" & str(15 + length) + vbcr mobcomm.output = pdu & chr$(26) sleep(1) sendsms = true end function |