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

📄 smg_recvthread.pas

📁 SPIG1.1.rar SPIG接口协议
💻 PAS
字号:
unit SMG_RecvThread;

interface

uses
  Classes, SysUtils, SP_SMG_DLL, Windows, ActiveX, ShellApi, DLL_Exports;

type
  Recv_Thread = class(TThread)
  private
    DeliverBuf: DeliverStr;
    procedure RecvBuffer;
    { Private declarations }
  protected
    procedure Execute; override;
  public
    constructor Create(FDeliver: DeliverStr; CreateSuspended: Boolean);
  end;

implementation

{ Important: Methods and properties of objects in VCL or CLX can only be used
  in a method called using Synchronize, for example,

      Synchronize(UpdateCaption);

  and UpdateCaption could look like,

    procedure Recv_Thread.UpdateCaption;
    begin
      Form1.Caption := 'Updated in a thread';
    end; }

{ Recv_Thread }
uses SPServer, SMG_DB;

procedure Recv_Thread.Execute;
begin
  { Place thread code here }
  FreeOnTerminate := True;
  RecvBuffer;
end;

constructor Recv_Thread.Create(FDeliver: DeliverStr; CreateSuspended: Boolean);
begin
 DeliverBuf := FDeliver;
 FreeOnTerminate := True;
 inherited Create(CreateSuspended);
end;

procedure Recv_Thread.RecvBuffer;
var
  cTemp:Char;
  Dest:PChar;
  MsgArray: array of Char;
  pReport:ReportStr;
  Z,I,Len,pLen:Integer;
  SckHandle:LongInt;
  pSPNum,pSrcNo,pTp_Pid,pTp_Udhi,pMsgContent,pMsgCoding:string;
  pSeqNum1,pSeqNum2,pSeqNum3:LongInt;
begin
 Dec(RI);
 FillChar(pReport,SizeOf(pReport),' ');
  with frmSGIP do
   begin
    with DeliverBuf do
     begin
      pSeqNum1:=SeqNum1;
      pSeqNum2:=SeqNum2;
      pSeqNum3:=SeqNum3;
      pSPNum:=SPNum;
      pSrcNo:=SrcNo;
      pTp_Pid:=Tp_Pid;
      pTp_Udhi:=Tp_Udhi;
      CurLogMsg(TRE,'序列号1:'+IntToStr(SeqNum1));
      CurLogMsg(TRE,'序列号2:'+IntToStr(SeqNum2));
      CurLogMsg(TRE,'序列号3:'+IntToStr(SeqNum3));
      CurLogMsg(TRE,'手机号:'+SrcNo);
      CurLogmsg(TRE,'SP号码:'+SPNum);
      CurLogmsg(TRE,'Tp_Pid:'+pTp_Pid);
      CurLogmsg(TRE,'Tp_Udhi:'+pTp_Udhi);
      CurLogmsg(TRE,'信息长度:'+IntToStr(MsgLen));
   if MsgCoding=#0 then
    begin
     CurLogMsg(TRE,'信息内容:'+MsgContent);
     CurLogMsg(TRE,'信息编码:'+'0');
    end;
   if (MsgCoding=#15)or(MsgCoding=#8) then
    begin
      if MsgCoding=#15 then CurLogMsg(TRE,'信息编码:15');
      if MsgCoding=#8 then CurLogMsg(TRE,'信息编码:8');
      Len := MsgLen;
      for I:=0 to MsgLen-1 do
       pMsgContent:=pMsgContent+IntToHex(Ord(MsgContent[I]),2);
      pMsgContent:=UnicodeToStr(pMsgContent);
      CurLogMsg(TRE,'信息内容:'+pMsgContent);
      SckHandle:=0;
     if SearchSckHandle(pSPNum,SckHandle) > 0 then
        SendBuffer(SckHandle,DeliverBuf,pReport,101);
      with frmSMGDB.tblDeliver do
       begin
        Open;
        Insert;
        Fields[1].Value:=pSeqNum1;
        Fields[2].Value:=pSeqNum2;
        Fields[3].Value:=pSeqNum3;
        Fields[4].Value:=pSrcNo;
        Fields[5].Value:=pSPNum;
        Fields[6].Value:=pTp_pid;
        Fields[7].Value:=pTp_udhi;
        Fields[8].Value:=pMsgCoding;
        Fields[9].Value:=pLen;
        Fields[10].Value:=pMsgContent;
        Post;
       end;
     end;
    end;
  end;
end;

end.

⌨️ 快捷键说明

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