📄 u_sms.~pas
字号:
save_inifile('config.ini','com0','set2',zcm+yxq+xym);
StatusBar1.Panels.Items[0].Text:='已注册';
END
else
begin
StatusBar1.Panels.Items[0].Text:='未注册';
showmessage('注册失败,请联系QQ:17184788,获取正确的注册码!');
end;
end;
procedure TForm1.N25Click(Sender: TObject);
begin
close;
end;
procedure TForm1.Timer_con(timer:ttimer;istart,iend,tInterval:integer);
var i:integer;
shijianc,divbbb:integer;
begin
timer.Enabled:=false;
StatusBar1.Panels.Items[2].Text:='已发:'+inttostr(had_send);
StatusBar1.Panels.Items[3].Text:='响应:'+inttostr(ssss);
StatusBar1.Panels.Items[5].Text:='待发:'+inttostr(all_no_list.Count);
divbbb:=(time_to_int(now())-start_time_int)+1;
StatusBar1.Panels.Items[6].Text:='总速度:'+inttostr(had_send*3600 div (divbbb));
StatusBar1.Panels.Items[7].Text:='接收:'+inttostr(read_all_msg.Count);
for i:=istart to iend do
begin
if ListView1.Items.Item[i].SubItems.Strings[0]<>inttostr(channels[i].channel_COM) then show_state(i,0, inttostr(channels[i].channel_COM));
// if ListView1.Items.Item[i].SubItems.Strings[2]<>inttostr(channels[i].limit)then show_state(i,2,inttostr(channels[i].limit));
case channels[i].channel_state of
0: // 停止
begin
if ListView1.Items.Item[i].SubItems.Strings[1]<>'停用' then
ListView1.Items.Item[i].SubItems.Strings[1]:='停用';
end;
10,11,33,34: //启动
begin
if ListView1.Items.Item[i].SubItems.Strings[1]<>'启动' then
ListView1.Items.Item[i].SubItems.Strings[1]:='启动'
else
ListView1.Items.Item[i].SubItems.Strings[1]:='启动.';
end;
12,13:
begin
if ListView1.Items.Item[i].SubItems.Strings[1]<>'读取信息' then
ListView1.Items.Item[i].SubItems.Strings[1]:='读取信息'
else
ListView1.Items.Item[i].SubItems.Strings[1]:='读取信息.';
end;
14,15: //启动失败
begin
if ListView1.Items.Item[i].SubItems.Strings[1]<>'删除信息' then
ListView1.Items.Item[i].SubItems.Strings[1]:='删除信息'
else
ListView1.Items.Item[i].SubItems.Strings[1]:='删除信息.'
end;
16,17,20: //提交消息 /显示速度
begin
if ListView1.Items.Item[i].SubItems.Strings[1]='提交消息' then
ListView1.Items.Item[i].SubItems.Strings[1]:='提交消息.'
else
ListView1.Items.Item[i].SubItems.Strings[1]:='提交消息';
//显示速度
shijianc:=time_to_int(now())-channels[i].start_time_int+1;
channels[i].current_speed:=channels[i].had_send*3600 div shijianc;
show_state(i,9,inttostr(channels[i].current_speed)+'/'+inttostr(channels[i].speed));
end;
23: //结束
begin
if ListView1.Items.Item[i].SubItems.Strings[1]<>'结束?!' then
ListView1.Items.Item[i].SubItems.Strings[1]:='结束?!';
end;
30: //消息响应
begin
if ListView1.Items.Item[i].SubItems.Strings[1]='发送中' then
ListView1.Items.Item[i].SubItems.Strings[1]:='发送中.'
else
ListView1.Items.Item[i].SubItems.Strings[1]:='发送中';
end;
40: //速度控制
begin
if ListView1.Items.Item[i].SubItems.Strings[1]='速度控制' then
ListView1.Items.Item[i].SubItems.Strings[1]:='速度控制.'
else
ListView1.Items.Item[i].SubItems.Strings[1]:='速度控制';
end
else //
begin
if ListView1.Items.Item[i].SubItems.Strings[1]='未知事件' then
ListView1.Items.Item[i].SubItems.Strings[1]:='未知事件.'
else
ListView1.Items.Item[i].SubItems.Strings[1]:='未知事件'
end;
end;
end;
if not Timer.Enabled then Timer.Enabled:=true;
end;
procedure TForm1.Timer_get(timer:ttimer;istart,iend,tInterval:integer);
var i,fi:integer;
in_int,csca_index:integer;
m_buf : array [0..3999] of Char;
begin
Timer.Enabled:=false;
for i:=istart to iend do
begin
if (channels[i].channel_COM>0 ) and (channels[i].channel_state>0 ) then
begin
{读取端口返回的信息}
FillChar(m_buf,4000,#0);
in_int:=sio_iqueue(channels[i].channel_COM);
if (in_int>0)and (in_int<4000) then
begin
sio_read(channels[i].channel_COM,@m_buf,in_int);
if (channels[i].channel_state<>30)then
begin
if (AnsiContainsStr(m_buf,'+CMTI'))THEN
begin
if (n11.Checked) then channels[i].channel_state:=12 ;
end
else if (AnsiContainsStr(m_buf,'RING'))THEN
begin
com_write(channels[i].channel_COM,'ath') ;
end
end;
end;
case channels[i].channel_state of
0:
begin
// channels[i].wait_timers:=0;
end;
10: //启动
begin
if send_cnmi(channels[i].channel_COM)>0 then channels[i].channel_state:=11;
channels[i].wait_timers:=0;
end;
11: //启动
begin
if (AnsiContainsStr(m_buf,'OK')) then
begin
if n11.Checked then channels[i].channel_state:=12 else channels[i].channel_state:=20 ;
channels[i].start_time_int:=TIME_to_int(now());
channels[i].had_send:=0;
end
else if channels[i].wait_timers>strtoint(write_read_timeout.Strings[4]) then
begin
channels[i].channel_state:=10;
channels[i].wait_timers:=0;
end;
inc(channels[i].wait_timers,timer.Interval);
end;
12: //获取信息 cmgl
begin
if send_cmgl(channels[i].channel_COM)>0 then channels[i].channel_state:=13;
channels[i].wait_timers:=0;
end;
13:begin
channels[i].read_all_buf:=channels[i].read_all_buf+m_buf;
IF TRIM(m_buf)<>'' THEN channels[i].wait_timers:=0;
if (AnsiContainsStr(m_buf,'OK')) then
begin
channels[i].read_all_buf:=trim(copy(channels[i].read_all_buf,pos('+CMGL:',channels[i].read_all_buf)+6,pos('OK',channels[i].read_all_buf)));
channels[i].read_all_buf:=read_sms_cmgl(channels[i].read_all_buf,channels[i].recv_sms_id);
if trim(channels[i].read_all_buf)<>'' then
begin
read_all_msg.Add('COM'+inttostr( channels[i].channel_COM)+' {'+trim(channels[i].read_all_buf)+'}'+#13) ;
read_all_msg.SaveToFile(log_path+'recvmsg_temp.txt');
memo1.Lines.Add('COM'+inttostr( channels[i].channel_COM)+' {'+trim(channels[i].read_all_buf)+'}'+#13)
end;
channels[i].channel_state:=14;
channels[i].read_all_buf:='';
channels[i].wait_timers:=0;
end
else if (AnsiContainsStr(m_buf,'ERROR'))then
begin
channels[i].channel_state:=12;
channels[i].read_all_buf:='';
channels[i].wait_timers:=0;
end
else if channels[i].wait_timers>strtoint(write_read_timeout.Strings[4]) then
begin
channels[i].channel_state:=20;
channels[i].wait_timers:=0;
end;
inc(channels[i].wait_timers,timer.Interval);
end;
14: //删除信息cmgd
begin
if channels[i].recv_sms_id.Count>0 then
begin
if send_cmgd(channels[i].channel_COM,strtoint(channels[i].recv_sms_id.Strings[0]))>0 then
channels[i].channel_state:=15;
channels[i].wait_timers:=0;
end
else
channels[i].channel_state:=20;
channels[i].wait_timers:=0;
end;
15:begin
if (AnsiContainsStr(m_buf,'OK')) then
begin
if channels[i].recv_sms_id.Count>0 then channels[i].recv_sms_id.Delete(0);
if channels[i].recv_sms_id.Count=0 then channels[i].channel_state:=20 else channels[i].channel_state:=14;
channels[i].wait_timers:=0;
end
else if (AnsiContainsStr(m_buf,'ERROR'))then
begin
channels[i].channel_state:=14;
channels[i].wait_timers:=0;
end
else if channels[i].wait_timers>strtoint(write_read_timeout.Strings[4]) then
begin
channels[i].channel_state:=20;
channels[i].wait_timers:=0;
end;
inc(channels[i].wait_timers,timer.Interval);
end;
20: //提交消息
begin
if zc(ypxlh,zcm,yxq,xym) then
begin
yxq:=inttostr(strtoint(yxq)-1);
xym:=inttostr(strtoint(yxq) mod 7);
save_inifile('config.ini','com0','set2',zcm+yxq+xym);
end
else
begin
showmessage('请输入注册码');
exit;
end;
if (all_no_list.Count>0) then
begin
channels[i].now_send_no:=channels[i].cz_mobile;
channels[i].messagestr:=all_no_list.Strings[0];
all_no_list.Delete(0);
all_no_list.SaveToFile(ExtractFilePath(Application.ExeName)+'last.txt');
show_state(i,6,channels[i].now_send_no);
show_state(i,8,channels[i].qz+channels[i].messagestr);
inc(had_send);
inc(channels[i].had_send);
channels[i].wait_timers:=0;
if send_msg(channels[i].channel_COM,'',channels[i].now_send_no,channels[i].qz+channels[i].messagestr)>0 then
begin
channels[i].channel_state:=30;
end
else
begin
channels[i].channel_state:=33;
end;
end
else
begin
channels[i].channel_state:=23;
end;
end; // 10,11,12,13: //启动中
23: //结束
begin
if (all_no_list.Count>0) then
begin
channels[i].channel_state:=20
end
end;
30: //消息响应
begin
if (AnsiContainsStr(m_buf,'+CMGS:')) then
begin //cmgs
inc(channels[i].sucess_count);
inc(ssss);
channels[i].wait_timers:=0;
show_state(i,7,'成功'+copy(m_buf,pos('CMGS',m_buf)+5,4));
show_state(i,4,inttostr(channels[i].sucess_count));
// show_state(i,2,inttostr(channels[i].limit));
show_state(i,3,formatdatetime('hh:mm:ss',now()));
// save_inifile('config.ini','com'+inttostr(i),'set5',INTTOSTR(channels[i].limit));
if channels[i].speed>599 then channels[i].channel_state:=20 else channels[i].channel_state:=40;
end //cmgs
else
if (AnsiContainsStr(m_buf,'ERROR')) THEN
begin //ERROR
inc(channels[i].false_count);
show_state(i,7,'失败');
show_state(i,5,inttostr(channels[i].false_count));
//channels[i].channel_state:=33;
channels[i].wait_timers:=0;
all_no_list.Insert(0,channels[i].messagestr);
all_no_list.SaveToFile(ExtractFilePath(Application.ExeName)+'last.txt');
if channels[i].speed>599 then channels[i].channel_state:=20 else channels[i].channel_state:=40;
end
else
begin //超时处理
if channels[i].wait_timers>strtoint(write_read_timeout.Strings[4]) then
begin
channels[i].channel_state:=10;
channels[i].wait_timers:=0;
all_no_list.Insert(0,channels[i].messagestr);
all_no_list.SaveToFile(ExtractFilePath(Application.ExeName)+'last.txt');
end
else
inc(channels[i].wait_timers,timer.Interval);
end;
end;
33:
BEGIN
channels[i].wait_timers:=0;
if colse_port(channels[i].channel_COM)=0 then channels[i].channel_state:=34;
END;
34:
BEGIN
if open_port(channels[i].channel_COM,channels[i].channel_COM_speed)=0 then
channels[i].channel_state:=10;
END;
40: //速度控制
begin
channels[i].speedt:=(3600 *1000) div (channels[i].speed)-strtoint(write_read_timeout.Strings[3]);
if channels[i].speedt<0 then channels[i].speedt:=0 ;
if (channels[i].wait_timers>channels[i].speedt) then
begin
channels[i].wait_timers:=0;
channels[i].channel_state:=20;
end;
inc(channels[i].wait_timers,timer.Interval);
end
else // 异常
begin
end;
end; //case
end; //end for
end ;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -