用到的代码如下:
代码如下:
function TForm_Main.DecodeRecvData(head, s: string; comm: Tcomm): Boolean;
var
len : string;
reclen : string;
t : string;
i, l : Integer;
oa : string; //源地址
ud : string; //用户信息
rd: string;
ct : Integer;
Str : String;
iThird : Integer;
begin
if s <> '' then
begin
t := s;
iThird := 16;
repeat
Str := Copy(t,iThird,1);
iThird := iThird + 1;
until
Str = '0';
reclen := Copy(t,iThird - 1,Length(t) - 8 - iThird+3);
t := reclen;
// len := Copy(t, 1, 2); //短信中心号码长度
len := '$' + Copy(t, 1, 2); //短信中心号码长度
i := 1 + 2 + 2 * StrToInt(len); //忽略短信中心号码
//效验接收长度是否正确
i := i + 2; //忽略
l := StrToInt('$' + Copy(t, i, 2)); //源地址长度
l := ((l div 2) + (l mod 2)) * 2;
i := i + 2;
i := i + 2; //忽略源地址类型
oa := TelNumDecode(Copy(t, i, l));
i := i + l;
i := i + 2; //忽略协议类型
ct := StrToInt('$' + Copy(t, i , 2)); //编码类型
i := i + 2;
rd := TimeStampDecode(Copy(t, i, 12));
i := i + 12;
i := i + 2; //忽略时区
len := '$' + Copy(t, i, 2);
i := i + 2;
ct := (ct and $0c) shr 2;
if ct = 2 then
ud := USC2Decode(Copy(t, i, StrToInt(len) * 3))
else if ct = 0 then
// ud := GsmAlphabetDecode(Copy(t, i, Length(t)-i+4))
ud := GsmAlphabetDecode(Copy(t, i, StrToInt(len) * 3))
else
ud := Copy(t, i, (StrToInt(len)) * 2);
end;
WriteDataRev(oa,ud,comm);
end;
请各位高人,看看如何解决,谢谢!