实达WM-100无线MODEM发送短消息的问题,不能发送中文!急(300分)

  • 主题发起人 主题发起人 雨季飘零
  • 开始时间 开始时间

雨季飘零

Unregistered / Unconfirmed
GUEST, unregistred user!
由实达厂家提供的DLL,我在DELPHI中调用,但是发送中文短消息收不到,只能发送英文的,以下是主窗体的代码,谁能帮我看看,谢谢了,主要看我注释的那一部门<br>unit main;<br><br>interface<br><br>uses<br> &nbsp;Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,<br> &nbsp;Dialogs, ExtCtrls, ComCtrls, StdCtrls, Buttons;<br><br>type<br> &nbsp;TsmsMain = class(TForm)<br> &nbsp; &nbsp;Panel1: TPanel;<br> &nbsp; &nbsp;Memo1: TMemo;<br> &nbsp; &nbsp;StatusBar1: TStatusBar;<br> &nbsp; &nbsp;Label1: TLabel;<br> &nbsp; &nbsp;eCom: TEdit;<br> &nbsp; &nbsp;Label2: TLabel;<br> &nbsp; &nbsp;eRate: TEdit;<br> &nbsp; &nbsp;label3: TLabel;<br> &nbsp; &nbsp;eCenter: TEdit;<br> &nbsp; &nbsp;eText: TEdit;<br> &nbsp; &nbsp;Label4: TLabel;<br> &nbsp; &nbsp;Label5: TLabel;<br> &nbsp; &nbsp;ePhone: TEdit;<br> &nbsp; &nbsp;BitBtn1: TBitBtn;<br> &nbsp; &nbsp;BitBtn2: TBitBtn;<br> &nbsp; &nbsp;BitBtn3: TBitBtn;<br> &nbsp; &nbsp;Button1: TButton;<br> &nbsp; &nbsp;BitBtn4: TBitBtn;<br> &nbsp; &nbsp;BitBtn5: TBitBtn;<br> &nbsp; &nbsp;BitBtn6: TBitBtn;<br> &nbsp; &nbsp;procedure FormShow(Sender: TObject);<br> &nbsp; &nbsp;procedure BitBtn1Click(Sender: TObject);<br> &nbsp; &nbsp;procedure Button1Click(Sender: TObject);<br> &nbsp; &nbsp;procedure BitBtn3Click(Sender: TObject);<br> &nbsp; &nbsp;procedure BitBtn2Click(Sender: TObject);<br> &nbsp; &nbsp;procedure OnFormClose(Sender: TObject; var Action: TCloseAction);<br> &nbsp; &nbsp;procedure BitBtn4Click(Sender: TObject);<br> &nbsp; &nbsp;procedure BitBtn5Click(Sender: TObject);<br> &nbsp; &nbsp;procedure BitBtn6Click(Sender: TObject);<br> &nbsp;private<br> &nbsp; &nbsp;{ Private declarations }<br> &nbsp;public<br> &nbsp; &nbsp;{ Public declarations }<br> &nbsp;end;<br> &nbsp;{设置通讯口:入口: szPort: 通讯端口名: &quot;COM1&quot;,&quot;COM2&quot;,&quot;COM3&quot;...<br> szRate: 通讯速率,通常取&quot;57600&quot;<br> &nbsp; &nbsp;返回: SUCC: 成功<br> FAIL: 失败<br> &nbsp; &nbsp;说明:在使用动态链接库对MODEM进行操作之前,请先调用该函数打开PC机的串口 }<br> &nbsp;function WM_init(szPort,szRate : pChar):integer;stdcall;external 'wmdll.dll';<br><br> &nbsp;{初始化与MODEM的通信:返回: SUCC: 成功<br> -1/-2/-3: 失败<br> -7 未打开串口<br> &nbsp; 说明:在串口设置成功后,请先调用该函数初始化MODEM}<br> &nbsp;function WmCommInit:short;stdcall;external 'wmdll.dll';<br><br> &nbsp;{设置信息中心:入口: szSmsCen: 信息中心号码: &quot;+8613800591500&quot;<br> &nbsp; 返回: SUCC: 成功<br> FAIL: 失败<br> -7 未打开串口<br> &nbsp; 说明:与手机的使用相同,在第一次使用MODEM进行短信通信功能之前,必须至少设置一次信息中心号码。 }<br> &nbsp;function SmsInit(szSmsCen:pChar):integer;stdcall;external 'wmdll.dll';<br><br><br> &nbsp;function Dial(szSmsCen:pChar):smallint;stdcall;external 'wmdll.dll';<br><br><br> &nbsp;{获得无线MODEM最多允许存储的信息数:入口: 无<br> &nbsp; 返回: -2: 与MODEM通信失败<br> -1: 解码错误<br> -7 未打开串口<br> &nbsp; 其他整数: 无线MODEM最多允许存储的信息数}<br> &nbsp;function Sms_Amount:integer;stdcall;external 'wmdll.dll';<br><br> &nbsp;{发送短消息:入口: szSmsBuf:存储发送的信息内容 ,最多允许发送70个中文。<br> uiSmsLen: 存储要发送的信息长度<br> phone: <br> &nbsp; 存储要发送的电话号码,格式为86138*******,即前面必须以86起始<br> &nbsp; 返回: SUCC: 成功<br> FAIL: 失败<br> -7 未打开串口}<br> &nbsp;function SmsSend(szSmsBuf:pchar;uiSmsLen:integer; phone:pchar):integer;stdcall;external 'wmdll.dll';<br><br> &nbsp;{读取存储序号为index的信息:入口:<br> &nbsp; index: 存储序号,(取值范围:1~最多存储的信息数,从Sms_Amount函数返回) szSmsBuf: 由用户定义,用来存储解码后的信息内容。缓存区大小不要小于140字节<br> &nbsp; iLenStr: 由用户定义,用来存储返回的信息内容长度<br> &nbsp; szSmsPhone: 由用户定义,用来存储该信息发送方的电话号码。<br> &nbsp; szSmsTime: 由用户定义,用来存储该信息发送的时间。格式如030305172536,表示03年03月05日17时25分36秒<br> &nbsp; szSmsCen: 由用户定义,用来存储该信息发送的信息中心号码。<br> &nbsp; 返回:<br> &nbsp; SUCC: 成功,并将解码后的信息内容、该信息发送方电话号码、信息中心号码、发送时间均存在相应的缓存区内。即上面定义的szSmsBuf、szSmsPhone、szSmsTime、szSmsCen<br> &nbsp; -1: 短消息读取失败<br> &nbsp; -2:该序号无对应信息<br> &nbsp; 0: 存在无法正确解码的编码,并将已经解好的部分存储在相应缓存区内,如同SUCC。<br> &nbsp; -5:由于信息长度错误,导致发送信息失败。<br> &nbsp; -7 未打开串口 }<br> &nbsp;function SmsSendText(szSmsBuf:pchar;uiSmsLen:integer; phone:pchar):integer;stdcall;external 'wmdll.dll';<br> &nbsp;{<br> &nbsp; &nbsp; &nbsp; &nbsp;以text方式发送短消息:入口:<br> &nbsp; 返回:<br> &nbsp; SUCC: 成功<br> &nbsp; FAIL: &nbsp; &nbsp; &nbsp; &nbsp;失败<br> &nbsp;}<br><br> &nbsp;function Sms_Read_VC(index:integer;szSmsBuf:pchar;var iLenStr:integer;szSmsPhone,szSmsTime,szSmsCen:pchar):integer;stdcall;external 'wmdll.dll';<br> &nbsp;function ReadNextSms(szSmsBuf:pchar;var iLenStr:integer;szSmsPhone,szSmsTime,szSmsCen:pchar):integer;stdcall;external 'wmdll.dll';<br><br> &nbsp;{删除短信息:入口: index ,将要删除的短信的序号<br> &nbsp; (取值范围:1~最多存储的信息数,从Sms_Amount函数返回)<br> &nbsp; 返回: SUCC: 成功<br> FAIL: 失败<br> -7 未打开串口}<br> &nbsp;function Sms_Del(index:integer):integer;stdcall;external 'wmdll.dll';<br><br> &nbsp;{关闭打开了的串口:返回: SUCC: 成功<br> 2 成功,与SUCC含义不同之处在于,它表示串口未用WM_init成功初始化过。<br> FAIL: 失败<br> &nbsp; 说明:<br> &nbsp; 一旦用WM_init函数设置通信串口之后,请调用该函数释放线程,否则会一直占用系统资源 }<br> &nbsp;function port_close:integer;stdcall;external 'wmdll.dll';<br><br>var<br> &nbsp;smsMain: TsmsMain;<br> &nbsp;iWm_init,iWmCommInit,ismsInit,ismsSend,iRead : integer;<br> &nbsp;sWmCommInit : short;<br> &nbsp;iIndex : integer;<br><br>implementation<br><br>{$R *.dfm}<br><br>procedure TsmsMain.FormShow(Sender: TObject);<br>begin<br> &nbsp;memo1.Clear ;<br>end;<br><br>procedure TsmsMain.BitBtn1Click(Sender: TObject);<br>var<br> &nbsp;sePhone,sCenter,sText : string;<br> &nbsp;pCenter : array[0..20] of char;<br> &nbsp;pPhone : array[0..20] of char;<br> &nbsp;pText &nbsp;: array[0..140] of char;<br> &nbsp;i,iLen : integer;<br>begin<br> &nbsp;if eText.Text = '' then &nbsp;begin<br> &nbsp; &nbsp;showmessage('发送短信内容不能为空!');<br> &nbsp; &nbsp;if eText.CanFocus then eText.SetFocus ;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;if ePhone.Text = '' then &nbsp;begin<br> &nbsp; &nbsp;showmessage('对方电话不能为空!');<br> &nbsp; &nbsp;if ePhone.CanFocus then ePhone.SetFocus ;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{设置通讯口}<br> &nbsp;iWm_init := Wm_init(pchar( trim(eCom.Text) ),pchar( trim(eRate.Text) ));<br> &nbsp;if iWm_init = 0 then begin<br> &nbsp; &nbsp;memo1.Lines.Add('设置通讯口失败!');<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{初始化MORDEM}<br> &nbsp;sWmCommInit := WmCommInit;<br> &nbsp;if sWmCommInit &lt;&gt; 1 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('初始化MORDEM失败!'+inttostr(iWmCommInit));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{设置短信中心号码}<br> &nbsp;sCenter := trim( eCenter.Text );<br> &nbsp;for i := 1 to length(eCenter.Text) do begin<br> &nbsp; &nbsp;pCenter[i-1] := sCenter;<br> &nbsp;end;<br> &nbsp;pCenter:=#0;<br> &nbsp;<br> &nbsp;ismsInit := smsInit( pCenter );<br> &nbsp;if ismsInit &lt;&gt; 1 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('设置短信中心号码失败(1)!'+inttostr(ismsInit));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end; &nbsp; &nbsp;<br> &nbsp;{发送短信}<br> &nbsp;sePhone := '86'+trim( trim( ePhone.Text ) );<br> &nbsp;for i := 1 to length( sePhone ) do begin<br> &nbsp; &nbsp;pPhone[i-1] := sePhone;<br> &nbsp;end;<br> &nbsp;pPhone:= #0;<br> &nbsp;<br> &nbsp;iLen := length( eText.Text );<br> &nbsp;sText := trim( eText.Text );<br> &nbsp;fillchar(ptext,sizeof(pText),ord(' '));<br> &nbsp;for i := 1 to length(sText) do &nbsp;begin<br> &nbsp; &nbsp;ptext[i-1] := sText;<br> &nbsp;end;<br> &nbsp;pText:=#0;<br> &nbsp;ismsSend := smsSend(pText,iLen,pPhone);<br> &nbsp;Application.ProcessMessages ;<br> &nbsp;if ismsSend = 1 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('发送成功!');<br> &nbsp; &nbsp;port_close;<br> &nbsp;end<br> &nbsp;else begin<br> &nbsp; &nbsp;Memo1.Lines.Add('发送失败!'+inttostr(ismsSend));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br><br>end;<br><br>procedure TsmsMain.Button1Click(Sender: TObject);<br>var<br> &nbsp;sCenter : string;<br> &nbsp;i : integer;<br> &nbsp;pCenter : array[0..20] of char;<br>begin<br> &nbsp;{设置通讯口}<br> &nbsp;iWm_init := Wm_init(pchar( trim(eCom.Text) ),pchar( trim(eRate.Text) ));<br> &nbsp;if iWm_init = 0 then begin<br> &nbsp; &nbsp;memo1.Lines.Add('设置通讯口失败!');<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{初始化MORDEM}<br> &nbsp;sWmCommInit := WmCommInit;<br> &nbsp;if sWmCommInit &lt;&gt; 1 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('初始化MORDEM失败!'+inttostr(iWmCommInit));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{设置短信中心号码}<br> &nbsp;sCenter := trim( eCenter.Text );<br> &nbsp;for i := 1 to length(eCenter.Text) do begin<br> &nbsp; &nbsp;pCenter[i-1] := sCenter;<br> &nbsp;end;<br> &nbsp;pCenter:=#0;<br><br> &nbsp;ismsInit := smsInit( pCenter );<br> &nbsp;if ismsInit &lt;&gt; 1 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('设置短信中心号码失败(2)!'+inttostr(ismsInit));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br><br> &nbsp;Memo1.Lines.Add('置短信中心号码成功!'+inttostr(ismsInit));<br><br>end;<br><br>procedure TsmsMain.BitBtn3Click(Sender: TObject);<br>begin<br> &nbsp;memo1.Clear ;<br>end;<br><br>procedure TsmsMain.BitBtn2Click(Sender: TObject);<br>var<br> &nbsp;sePhone,sCenter,sText : string;<br> &nbsp;pCenter : array[0..20] of char;<br> &nbsp;pPhone : array[0..20] of char;<br> &nbsp;pTime : array[0..12] of char;<br> &nbsp;pText &nbsp;: array[0..140] of char; {接收的缓冲区}<br> &nbsp;i,iLen : integer;<br>begin<br> &nbsp;{设置通讯口}<br> &nbsp;iWm_init := Wm_init(pchar( trim(eCom.Text) ),pchar( trim(eRate.Text) ));<br> &nbsp;if iWm_init = 0 then begin<br> &nbsp; &nbsp;memo1.Lines.Add('设置通讯口失败!');<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{初始化MORDEM}<br> &nbsp;sWmCommInit := WmCommInit;<br> &nbsp;if sWmCommInit &lt;&gt; 1 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('初始化MORDEM失败!'+inttostr(iWmCommInit));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{设置短信中心号码}<br> &nbsp;sCenter := trim( eCenter.Text );<br> &nbsp;for i := 1 to length(eCenter.Text) do begin<br> &nbsp; &nbsp;pCenter[i-1] := sCenter;<br> &nbsp;end;<br> &nbsp;pCenter:=#0;<br> &nbsp;ismsInit := smsInit( pCenter );<br> &nbsp;if ismsInit &lt;&gt; 1 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('设置短信中心号码失败(3)!'+inttostr(ismsInit));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{取存储短信最大数}<br> &nbsp;iIndex := sms_Amount;<br> &nbsp;if iIndex &lt; 0 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('取存储最大数错误!'+inttostr(iIndex));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br><br> &nbsp;Memo1.Lines.Add('最多可存储短消息条数:'+inttostr(iIndex));<br><br> &nbsp;if iIndex = 0 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('目前没有短信!'+inttostr(iIndex));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{读取短信信息}<br> &nbsp;iLen := 140;<br> &nbsp;for i := 1 to iIndex do begin<br> &nbsp; &nbsp;fillchar(ptext,sizeof(pText),ord(' '));{初始化缓冲区}<br> &nbsp; &nbsp;fillchar(pPhone,sizeof(pPhone),ord(' '));<br> &nbsp; &nbsp;fillchar(pTime,sizeof(pTime),ord(' '));<br> &nbsp; &nbsp;fillchar(pCenter,sizeof(pCenter),ord(' '));<br> &nbsp; &nbsp;iRead := Sms_Read_VC(i,pText,iLen,pPhone,pTime,pCenter);<br> &nbsp; &nbsp;if iRead &lt;&gt; 1 then begin<br> &nbsp; &nbsp; &nbsp;Memo1.Lines.Add('接收第'+inttostr(i)+'条短信失败!'+inttostr(iRead));<br> &nbsp; &nbsp; &nbsp;if i = iIndex then begin<br> &nbsp; &nbsp; &nbsp; // port_close;<br> &nbsp; &nbsp; &nbsp; &nbsp;break;<br> &nbsp; &nbsp; &nbsp;end;<br> &nbsp; &nbsp; &nbsp;continue;<br> &nbsp; &nbsp;end;<br> &nbsp; &nbsp;memo1.Lines.Add('发送号码:'+pPhone+' 时间:'+pTime+'内容:'+pText+'短信中心:'+pCenter);<br> &nbsp;end;<br> &nbsp;{删除短信}<br><br>end;<br><br>procedure TsmsMain.OnFormClose(Sender: TObject; var Action: TCloseAction);<br>begin<br> &nbsp;port_close;<br>end;<br>procedure TsmsMain.BitBtn4Click(Sender: TObject);<br>var<br> &nbsp;sePhone,sCenter,sText : string;<br> &nbsp;pCenter : array[0..20] of char;<br> &nbsp;pPhone : array[0..20] of char;<br> &nbsp;pText &nbsp;: array[0..140] of char;<br> &nbsp;i,iLen : integer;<br>begin<br> &nbsp;if eText.Text = '' then &nbsp;begin<br> &nbsp; &nbsp;showmessage('发送短信内容不能为空!');<br> &nbsp; &nbsp;if eText.CanFocus then eText.SetFocus ;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;if ePhone.Text = '' then &nbsp;begin<br> &nbsp; &nbsp;showmessage('对方电话不能为空!');<br> &nbsp; &nbsp;if ePhone.CanFocus then ePhone.SetFocus ;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{设置通讯口}<br> &nbsp;iWm_init := Wm_init(pchar( trim(eCom.Text) ),pchar( trim(eRate.Text) ));<br> &nbsp;if iWm_init = 0 then begin<br> &nbsp; &nbsp;memo1.Lines.Add('设置通讯口失败!');<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{初始化MORDEM}<br> &nbsp;sWmCommInit := WmCommInit;<br> &nbsp;if sWmCommInit &lt;&gt; 1 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('初始化MORDEM失败!'+inttostr(iWmCommInit));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{设置短信中心号码}<br> &nbsp;sCenter := trim( eCenter.Text );<br> &nbsp;for i := 1 to length(eCenter.Text) do begin<br> &nbsp; &nbsp;pCenter[i-1] := sCenter;<br> &nbsp;end;<br> &nbsp;pCenter:=#0;<br> &nbsp;ismsInit := smsInit( pCenter );<br> &nbsp;if ismsInit &lt;&gt; 1 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('设置短信中心号码失败(4)!'+inttostr(ismsInit));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{发送短信}<br> &nbsp;sePhone := trim( trim( ePhone.Text ) );<br> &nbsp;for i := 1 to length(ePhone.Text) do begin<br>//这是我的注释,关键问题就在这里<br> &nbsp; &nbsp;pPhone[i-1] := sePhone;<br> &nbsp;end;<br> &nbsp;pPhone:= #0;<br><br> &nbsp;iLen := length( eText.Text );<br> &nbsp;sText := trim( eText.Text );<br> &nbsp;fillchar(ptext,sizeof(pText),ord(' '));<br><br> for i := 1 to length(sText) do &nbsp;begin<br> &nbsp; &nbsp;ptext [i-1]:= sText;<br> end;<br> &nbsp;pText:=#0;<br> &nbsp;ismsSend := smsSendText(pText,iLen,pPhone);<br> &nbsp;Application.ProcessMessages ;<br> &nbsp;if ismsSend = 1 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('发送成功!');<br> &nbsp; &nbsp;port_close;<br> &nbsp;end<br> &nbsp;else begin<br> &nbsp; &nbsp;Memo1.Lines.Add('发送失败!'+inttostr(ismsInit));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br><br>end;<br><br>procedure TsmsMain.BitBtn5Click(Sender: TObject);<br>var<br> &nbsp;sePhone,sCenter,sText : string;<br> &nbsp;pCenter : array[0..20] of char;<br> &nbsp;pPhone : array[0..20] of char;<br> &nbsp;pTime : array[0..12] of char;<br> &nbsp;pText &nbsp;: array[0..140] of char; {接收的缓冲区}<br> &nbsp;i,iLen : integer;<br>begin<br> &nbsp;{设置通讯口}<br> &nbsp;iWm_init := Wm_init(pchar( trim(eCom.Text) ),pchar( trim(eRate.Text) ));<br> &nbsp;if iWm_init = 0 then begin<br> &nbsp; &nbsp;memo1.Lines.Add('设置通讯口失败!');<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{初始化MORDEM}<br> &nbsp;sWmCommInit := WmCommInit;<br> &nbsp;if sWmCommInit &lt;&gt; 1 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('初始化MORDEM失败!'+inttostr(iWmCommInit));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{设置短信中心号码}<br> &nbsp;sCenter := trim( eCenter.Text );<br> &nbsp;for i := 1 to length(eCenter.Text) do begin<br> &nbsp; &nbsp;pCenter[i-1] := sCenter;<br> &nbsp;end;<br> &nbsp;pCenter:=#0;<br><br> &nbsp;ismsInit := smsInit( pCenter );<br><br> &nbsp;if ismsInit &lt;&gt; 1 then begin<br> &nbsp; &nbsp;{ShowMessage('设置失败!');}<br> &nbsp; &nbsp;Memo1.Lines.Add('设置短信中心号码失败(5)!'+inttostr(ismsInit));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br><br> &nbsp;{取存储短信最大数}<br> &nbsp;iIndex := sms_Amount;<br> &nbsp;if iIndex &lt; 0 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('取存储最大数错误!'+inttostr(iIndex));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br><br> &nbsp;Memo1.Lines.Add('最多可存储短消息条数:'+inttostr(iIndex));<br><br> &nbsp;if iIndex = 0 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('目前没有短信!'+inttostr(iIndex));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{读取短信信息}<br> &nbsp;iLen := 140;<br> &nbsp;while(TRUE) do<br> &nbsp;begin<br> &nbsp; &nbsp;fillchar(ptext,sizeof(pText),ord(' '));{初始化缓冲区}<br> &nbsp; &nbsp;fillchar(pPhone,sizeof(pPhone),ord(' '));<br> &nbsp; &nbsp;fillchar(pTime,sizeof(pTime),ord(' '));<br> &nbsp; &nbsp;fillchar(pCenter,sizeof(pCenter),ord(' '));<br> &nbsp; &nbsp;iRead := ReadNextSms(pText,iLen,pPhone,pTime,pCenter);<br> &nbsp; &nbsp;CASE iRead Of<br> &nbsp; &nbsp; &nbsp; &nbsp;1:<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BEGIN<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Memo1.Lines.Add('接收短信成功,后面还有短信未读出!'+inttostr(iRead));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;memo1.Lines.Add('发送号码:'+pPhone+' 时间:'+pTime+'内容:'+pText+'短信中心:'+pCenter);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;<br> &nbsp; &nbsp; &nbsp; &nbsp;2:<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BEGIN<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Memo1.Lines.Add('接收短信成功,后面已经没有短信未读出!'+inttostr(iRead));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;memo1.Lines.Add('发送号码:'+pPhone+' 时间:'+pTime+'内容:'+pText+'短信中心:'+pCenter);<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;<br> &nbsp; &nbsp; &nbsp; &nbsp;3:<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BEGIN<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Memo1.Lines.Add('缓冲区中已经没有短信未读出!'+inttostr(iRead));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BREAK;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;<br> &nbsp; &nbsp; &nbsp; &nbsp;-1:<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BEGIN<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Memo1.Lines.Add('读取失败(可能是串口没有初始化)!'+inttostr(iRead));<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;BREAK;<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;END<br> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;;<br> &nbsp; &nbsp; &nbsp; &nbsp;0:Memo1.Lines.Add('存在无法正确解码的编码!'+inttostr(iRead));<br> &nbsp; &nbsp;END;<br><br> &nbsp; &nbsp;{测试单条}<br> &nbsp; &nbsp;{break;}<br> &nbsp;end;<br> &nbsp;{删除短信}<br><br>end;<br><br>procedure TsmsMain.BitBtn6Click(Sender: TObject);<br>VAR<br> &nbsp;sCenter : string;<br> &nbsp;i : integer;<br> &nbsp;pCenter : array[0..20] of char;<br> &nbsp;smliDial:smallint;<br>begin<br> &nbsp;{设置通讯口}<br> &nbsp;iWm_init := Wm_init(pchar( trim(eCom.Text) ),pchar( trim(eRate.Text) ));<br> &nbsp;if iWm_init = 0 then begin<br> &nbsp; &nbsp;memo1.Lines.Add('设置通讯口失败!');<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{初始化MORDEM}<br> &nbsp;sWmCommInit := WmCommInit;<br> &nbsp;if sWmCommInit &lt;&gt; 1 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('初始化MORDEM失败!'+inttostr(iWmCommInit));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br> &nbsp;{进行拨号}<br> &nbsp;sCenter := trim( ePhone.Text );<br> &nbsp;for i := 1 to length(ePhone.Text) do begin<br> &nbsp; &nbsp;pCenter[i-1] := sCenter;<br> &nbsp;end;<br> &nbsp;pCenter := #0;<br><br> &nbsp;smliDial := Dial( pCenter );<br><br> &nbsp;if smliDial &lt;&gt; 1 then begin<br> &nbsp; &nbsp;Memo1.Lines.Add('拨号失败!'+inttostr(smliDial));<br> &nbsp; &nbsp;port_close;<br> &nbsp; &nbsp;exit;<br> &nbsp;end;<br><br> &nbsp;Memo1.Lines.Add('拨号成功!'+inttostr(smliDial));<br>end;<br><br>end.
 
www.source520.com 再次更新近3万代码,全部免费免注册狂下载
 

Similar threads

S
回复
0
查看
3K
SUNSTONE的Delphi笔记
S
S
回复
0
查看
2K
SUNSTONE的Delphi笔记
S
I
回复
0
查看
805
import
I
后退
顶部