超长短信:就是多条发送,到对方手机上合成为一条的短信。可以发小说等,长字短信。 unit imSMSUtils; {******************************************************* masterjames *******************************************************} interface uses Math,Classes,SysUtils; type TimSMSUtils = class private FSigalHead : string; function SetSigal(x, y: integer): string; public constructor Create; function StrToUCS2(vInput:WideString): WideString; function USC2ToStr(vInput:WideString): WideString; function GetMobilePDU(vStr:string) : string; function GetMsgLenPDU(vMsg:string) : string; overload; function GetMsgLenPDU(vLen:integer) : string; overload; function GetSMSHeadPDU(vTotal,vCurr: integer) : string; function GetATCMGSLen(vPDU:string): integer; end; implementation function TimSMSUtils.StrToUCS2(vInput:WideString): WideString; var i: Integer; begin Result := ''; for i := 1 to Length(vInput) do Result := Result + Format('%4.4X',[ord(vInput[i])]); end; function TimSMSUtils.GetMobilePDU(vStr:string) : string; var TempPchar : Pchar; i : integer; Str : string; begin if(Copy(vStr,1,1)='+')then vStr := Copy(vStr,2,Length(vStr)-1); //去掉手机号码中的’+’ if((Length(vStr) mod 2)=1) then vStr := vStr + 'F'; TempPchar := Pchar(vStr); i := 0; Str := ''; while i < Length(TempPchar) do begin Str := Str + TempPchar[i+1] + TempPchar[i]; i := i + 2; end; Result := Str; end; function TimSMSUtils.GetMsgLenPDU(vMsg:string): string; var Tmp : integer; Str : string; begin Tmp:= Length(StrToUCS2(vMsg)) div 2; Str := format('%X',[tmp]); if Length(Str) < 2 then Str:= '0' + Str; Result := Str; end; function TimSMSUtils.GetMsgLenPDU(vLen: integer): string; var Str : string; begin vLen := vLen *2; Str := format('%X',[vLen]); if Length(Str) < 2 then Str:= '0' + Str; Result := Str; end; function TimSMSUtils.GetSMSHeadPDU(vTotal,vCurr: integer): string; begin Result := '0500030'+FSigalHead+IntToStr(vTotal)+ '0'+IntToStr(vCurr+1); end; function TimSMSUtils.SetSigal(x, y: integer): string; const BitA : array[0..5] of string =('A','B','C','D','E','F'); var z,BitB : integer; vStrA,vStrB,vResult : string; begin x := random(10); y := random(10); z := random(10); asm MOV EAX,x MOV ECX,y ADD EAX,ECX MOV BitB,EAX end; if z > 5 then z := 5 ; vStrA := BitA[z]; case Length(IntToStr(BitB)) of 0 : vStrB := '0'; 1 : vStrB := IntToStr(BitB); 2 : vStrB := '5'; end; vResult := Trim(vStrA + vStrB); if Length(vResult) > 2 then vResult := 'A0'; Result := vResult; end; function TimSMSUtils.GetATCMGSLen(vPDU:string): integer; var ByteCount : integer; begin ByteCount :=(Length(vPDU)-2) div 2; Result := ByteCount; end; function TimSMSUtils.USC2ToStr(vInput: WideString): WideString; var vWideStr : WideString; begin Result := vWideStr; end; constructor TimSMSUtils.Create; begin FSigalHead := SetSigal(2,5); end; end.