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

📄 smspublic.pas

📁 Delphi写的CMPP短信协议控件
💻 PAS
字号:
unit SMSPUBLIC;

interface
uses
  Windows, Messages, SysUtils, Classes,math,SgipType;

function intSwap(input:longword):Longword;
function int64Swap(input:int64):int64;
function WordSwap(input:word):word;
function UnicodeSwap(input:TCharArray;InputL:integer):TCharArray;
function arr2Str(input:array of char;inputL:integer):String;
function str2arr(input:String;var output:array of char):integer;

implementation
function intSwap(input:longword):Longword;
type
     TSwapint=array[0..3]of byte;
     PSwapint=^TSwapint;
var
     tmp:PSwapint;
     ByteTmp:Byte;
     PTmp:Pointer;
     PlongWord:^Longword;
begin
     Ptmp:=@input;
     tmp:=Ptmp;
     ByteTmp:=tmp^[0];
     Tmp^[0]:=Tmp^[3];
     Tmp^[3]:=ByteTmp;
     ByteTmp:=Tmp^[1];
     tmp^[1]:=Tmp^[2];
     tmp[2]:=Bytetmp;
     PTmp:=Tmp;
     PLongWord:=PTmp;
     result:=Plongword^;

end;
function int64Swap(input:int64):int64;
type
     TSwapint=array[0..7]of byte;
     PSwapint=^TSwapint;
var
     tmp:PSwapint;
     ByteTmp:Byte;
     PTmp:Pointer;
     PlongWord:^Longword;
begin
     Ptmp:=@input;
     tmp:=Ptmp;
     ByteTmp:=tmp^[0];
     Tmp^[0]:=Tmp^[7];
     Tmp^[7]:=ByteTmp;

     ByteTmp:=Tmp^[1];
     tmp^[1]:=Tmp^[6];
     tmp[6]:=Bytetmp;

     ByteTmp:=Tmp^[2];
     tmp^[2]:=Tmp^[5];
     tmp[5]:=Bytetmp;

     ByteTmp:=Tmp^[3];
     tmp^[3]:=Tmp^[4];
     tmp[4]:=Bytetmp;

     PTmp:=Tmp;
     PLongWord:=PTmp;
     result:=Plongword^;

end;
function WordSwap(input:word):word;
type
     TSwapint=array[0..1]of byte;
     PSwapint=^TSwapint;
var
     tmp:PSwapint;
     ByteTmp:Byte;
     PTmp:Pointer;
     PWord:^word;
begin
     Ptmp:=@input;
     tmp:=Ptmp;
     ByteTmp:=tmp^[0];
     Tmp^[0]:=Tmp^[1];
     Tmp^[1]:=ByteTmp;
     PTmp:=Tmp;
     PWord:=PTmp;
     result:=Pword^;

end;
function UnicodeSwap(input:TCharArray;inputL:integer):TCharArray;
var
     Tmp:TCharArray;
     CharTmp:Char;
     i:integer;
begin
     i:=0;
     tmp:=input;
     While i<inputL do
     begin
         CharTmp:=tmp[i];
         tmp[i]:=tmp[i+1];
         tmp[i+1]:=CharTmp;
         i:=i+2;
     end;
     Result:=tmp;
end;
function arr2Str(input:array of char;inputL:integer):String;
var
     tmp0:pointer;
     tmp2:pchar;
begin
     tmp0:=@input;
     tmp2:=tmp0;
     Result:=string(tmp2);
{     setlength(tmp,inputl);
     for i:=0 to inputL-1 do
     begin
         tmp[i+1]:=input[i];
     end;
     Result:=Tmp;}

end;
function str2arr(input:String;var output:array of char):integer;
var
     i:integer;
     len:integer;
begin
     len:=length(output);
     for i:=0 to len-1 do output[i]:=#0;
     len:=Min(length(input),length(output));
     for i:=0 to len-1 do
     begin
         output[i]:=input[i+1];
     end;
     result:=len;
end;

end.

⌨️ 快捷键说明

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