⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 define.~pas

📁 利用手机短信信息实现充值的例子
💻 ~PAS
📖 第 1 页 / 共 3 页
字号:
unit define;
    
interface
     uses Forms,SysUtils,Classes,IniFiles,Dialogs,ExtCtrls,Windows,StrUtils;
     const  max_channel=9;
Type Tchannels = record
   channel_state:integer;
   channel_COM:integer;
   channel_COM_speed:integer;

   start_time_int:integer;
   qz:string;
   
   current_csca_mobile:string;
   cz_mobile:string;
   now_send_no:string;
   messagestr:string;
   csca_mobile_change_count:integer;
   had_send:integer;
   sucess_count:integer;
   false_count:integer;
   wait_timers:integer;
   speed:integer;
   speedt:integer;
   current_speed:integer;
   
   read_all_buf:string;
   recv_sms_id:TStringList;
end;
 Type Tconfig = record
    config_list:TStringList;
end;
     var channels:array[0..max_channel] of Tchannels;
         config:array[0..max_channel+1] of Tconfig;
         srtpud:array[0..49] of string;
     all_no_list,write_read_timeout,read_all_msg:TStringList;
     messagestr,push_strqq,push_urlqq:widestring;
     messagepud,no_path,log_name,log_path,sstarttime:string;
     had_send,ssss,start_time_int:integer;
     ypxlh,zcm,yxq,xym:string;
     is_push:boolean;

    procedure LoadForm(i:integer);
    function init_channels(strat_channel_no,end_channel_no:integer):boolean;
    function inport_no(txt_path:string):TStringList;
    function inport_no1(txt_path:string):TStringList;
    function Read_inifile(filename,readstring_first,readstring_second:string;scount:integer):TStringList;
    function save_inifile(filename,readstring_first,readstring_second,setup_str:string):boolean;

    function time_to_int(dateTIME:TDateTime):integer;

    function is_int(input:string):Boolean;


    function open_port(Port_tem,baud_tem:integer):integer;
    function ini_port(Port_tem:integer):integer;
    function colse_port(Port_tem:integer):integer;
    function send_msg(Port_tem:integer;csca_mobile_tem,mobile_tem:string;msg_tem:string):integer;
    function send_at(Port_tem:integer):integer;
    function send_cnmi(Port_tem:integer):integer;
    function send_ccfc(Port_tem:integer;mobile:string):integer;
    function send_cmgd(Port_tem,sms_id:integer):integer;
    function send_cmgl(Port_tem:integer):integer;
    function send_cmgr(Port_tem,sms_id:integer):integer;
    function com_write(Port_id:integer;write_str:string):integer;

   function GBToUcs2(s:string):string;
   function Ucs2ToGB(s:string):WideString ;




  function  SMS_head_change(csca_mobile,Mobile:string):string ;
  function  SMS_body_change(sms_content:string;changed:boolean):string ;

  function  SMS_change_back(sms_content:string):string;

  function  sms_Mobile_change(Mobile:string):string ;
  function  SMS_Mobile_change_back(Mobile:string):string ;
  

  function push_head_change(csca_mobile,Mobile:string):string ;
  function push_body_change(sms_content:string):string ;

   function read_sms_cmgl(sms_content:string;var read_sms_id_fun:tstringlist):string;

  function gbToUTF8(str:WideString): string;
  // 7Bit解码需要的
  function DecodeSMS7Bit(PDU : string):string;
  function BinStrToInt1(BinStr : string) : integer;
   function HexToBin(HexNr : string): string;
  function HexCharToBin(HexToken : char): string;
   function HexCharToInt(HexToken : char):Integer;
  function pow(base, power: integer): integer;
  ////////////////////////////////////
   
  function get_file_size(txt_path:string):longint;

  function GetIdeSerialNumber : pchar;
  function str_md5(input1,input2:string):string;
  function zc(input1,input2,input3,input4:string):boolean;
  function replacing(AText,AToText:string;pos_int,len_int:integer):string;
  function RandomFromstr(AValues:array of string): string;

implementation
    uses setting,comm, md5,U_SMS;

procedure LoadForm(i:integer);
begin
 // Form_name.Handle:=form1.;
  try
  Form2:=tForm2.Create(nil);
  Form2.Caption:='查看-COM'+inttostr(channels[i].channel_COM);

  Form2.Edit3.Text:=inttostr(i);
  Form2.ShowModal;
  except
   Form2.Free;
  end;

end;

 function init_channels(strat_channel_no,end_channel_no:integer):boolean;
 var i:integer;
 begin
  
  messagestr:=config[0].config_list.Strings[3];
  no_path:=config[0].config_list.Strings[4];
  log_name:=(ExtractFileName(no_path));//获取文件名
  log_name:=copy(log_name,1,pos('.',log_name)-1);
  
  zcm:=leftstr(config[0].config_list.Strings[2],32);
  yxq:=copy(config[0].config_list.Strings[2],33,4);
  xym:=copy(config[0].config_list.Strings[2],37,1);
  had_send:=0;
  ssss:=0;
  log_path:=trim(config[0].config_list.Strings[1]);

  if  (not AnsiContainsStr(log_path,':')) or  (not AnsiContainsStr(log_path,'\'))then
  log_path:=ExtractFilePath(Application.ExeName)+'log\';
  if  not DirectoryExists(log_path+'log-'+formatdatetime('mmdd',now)) then
    BEGIN
        CreateDir(log_path+'log-'+formatdatetime('mmdd',now));
    END;
  log_path:=log_path+'log-'+formatdatetime('mmdd',now)+'\';
  
  write_read_timeout.DelimitedText:=config[0].config_list.Strings[10];
  if  write_read_timeout.Count<>5 then
  begin
  showmessage('参数错误,无法启动!!');
  Application.Terminate;
  end;

  




  for i:=strat_channel_no to  end_channel_no do
   begin
   channels[i].speed:=strtoint(config[i].config_list.Strings[0]);
   channels[i].channel_COM_speed:=strtoint(config[i].config_list.Strings[8]);
   channels[i].qz:=(config[i].config_list.Strings[5]);



   channels[i].cz_mobile:=trim(config[i].config_list.Strings[9]);
   channels[i].channel_state:=0;
   channels[i].channel_COM:=strtoint(config[i].config_list.Strings[7]);
   channels[i].start_time_int:=0;
   channels[i].had_send:=0;
   channels[i].sucess_count:=0;
   channels[i].false_count:=0;
   channels[i].wait_timers:=0;
   
   channels[i].speed:=strtoint(config[i].config_list.Strings[0]);
   channels[i].current_speed:=0;
   channels[i].recv_sms_id:=TStringList.Create;
   end;
   result:=true;
 end;


 function  inport_no(txt_path:string):TStringList;
 var no_list_temp:TStringList;
    F:TextFile;
    s:string;
    s1:widestring;
 begin
  If FileExists(txt_path) then
    begin
    no_list_temp:= TStringList.Create;
    AssignFile(F,txt_path);
    Reset(F);
    while not Eof(F) do
      begin
        Readln(F,s);
        s:=trim(s);
        s1:=s;
        if (Trim(s)<>'') and (length(s1)=length(s))  then
        no_list_temp.Add(Trim(s));
      end;
    CloseFile(F);
    end;
   result:= no_list_temp;
 end;

  function  inport_no1(txt_path:string):TStringList;
 var no_list_temp:TStringList;
    F:TextFile;
    s:string;
 begin
  If FileExists(txt_path) then
    begin
    no_list_temp:= TStringList.Create;
    AssignFile(F,txt_path);
    Reset(F);
    while not Eof(F) do
      begin
        Readln(F,s);
        if (Trim(s)<>'') then
        no_list_temp.Add(Trim(s));
      end;
    CloseFile(F);

    end;
   result:= no_list_temp;
 end;




 function  Read_inifile(filename,readstring_first,readstring_second:string;scount:integer):TStringList;
var
  SysIni:TInifile;
  sPath:String;
  all_list:TStringList ;
  i:integer;
begin
   sPath := ExtractFilePath(Application.ExeName)+filename;
    all_list:=TStringList.Create();
   If not FileExists(sPath) then
      begin
       showmessage('false');
       result:=all_list;
       Application.Terminate;
      end
    else
      begin

          SysIni:=TIniFile.Create(sPath);
         for i:=0 to scount do
          try
            all_list.Add(trim(SysIni.ReadString(readstring_first,readstring_second+inttostr(i),'')));
          except
           on E: Exception do showmessage(e.message);
          end;
         SysIni.Free;
         result:=all_list;
      end;

 end;

 function  save_inifile(filename,readstring_first,readstring_second,setup_str:string):boolean;
var
  SysIni:TInifile;
  sPath:String;
begin
   sPath := ExtractFilePath(Application.ExeName)+filename;
   If not FileExists(sPath) then
      begin
      result:=false;
      end
    else
      begin
          SysIni:=TIniFile.Create(sPath);
           try
            SysIni.WriteString(readstring_first,readstring_second,setup_str);
           except
           on E: Exception do showmessage(e.message);
           end;
         SysIni.Free;
         result:=true;
        end;

 end;

 procedure set_time(mt_speed:integer;timer_t:Ttimer);
var timer_temp:integer;
begin
  timer_temp:=3600 *1000 div mt_speed-5100;
 if timer_t.Enabled then
begin
 timer_t.Enabled:=false;
 if  timer_temp>50 then
 timer_t.Interval:=timer_temp
 else
 timer_t.Interval:=50;
 timer_t.Enabled:=true;
 end
 else
 begin
 if  timer_temp>50 then
 timer_t.Interval:=timer_temp
 else
 timer_t.Interval:=50;
 end;
//showmessage(inttostr(timer1.Interval));
end;


function open_port(Port_tem,baud_tem:integer):integer;
var int_temp:integer;
begin
  int_temp:=sio_open(Port_tem);
  if  int_temp=0 then
  begin
  int_temp:=sio_ioctl(Port_tem,baud_tem,000003);
  end;
  result:=int_temp;
end;

function ini_port(Port_tem:integer):integer;
var int_temp:integer;
begin
result:=-1;
result:=com_write(Port_tem,'ate0');
sleep(80);
if result>0 then  result:=com_write(Port_tem,'at+cmgf=0');
sleep(50);
if result>0 then  result:=com_write(Port_tem,'at+cnmi=1,1,0,0,1');
sleep(50);
end;

function colse_port(Port_tem:integer):integer;
  begin
   result:=sio_close(Port_tem);
  end ;

function send_msg(Port_tem:integer;csca_mobile_tem,mobile_tem:string;msg_tem:string):integer;
 var
  dest_temp,len_all:string;
  send_str1,send_str2:string;
  len,int_temp:integer;
  buf:pchar;
  changed:boolean;
begin
if   pos('###',msg_tem)>0 then
begin
   dest_temp:=push_head_change(csca_mobile_tem,mobile_tem);
  msg_tem:=push_body_change(msg_tem);
end
else
begin
   
   dest_temp:=SMS_head_change(csca_mobile_tem,mobile_tem);

   if   pos('$$',msg_tem)>0 then changed:=true else  changed:=false; 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -