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

📄 unitwjs.pas

📁 手机短信发送源码
💻 PAS
字号:
unit UnitWJS;

interface

uses stdctrls,buttons,dbierrs,DBTables,bde,dialogs,TLHelp32,windows,Sysutils,forms,classes,winsock,
     Controls,math;

procedure ShowMessage2(msg:string);
procedure wait(ticks:dword);
function Replace(var Str:string;BeReplace,WantToReplace:string;CaseOrNot:boolean):integer;
function WordToHex(i:word):string;
function LongToHex(i:longword):string;

implementation

function WordToHex(i:word):string;
begin
   setlength(result,2);
   pword(@result[1])^:=i;
end;

function LongToHex(i:longword):string;
begin
   setlength(result,4);
   plongword(@result[1])^:=i;
end;

function Replace(var Str:string;BeReplace,WantToReplace:string;CaseOrNot:boolean):integer;
var
   s:string;
   i,j,LenStr,LenBe:integer;
   function CompChar(c1,c2:char;CaseOrNot:boolean):boolean;
   begin
      if(c1=c2)then result:=true
      else if (CaseOrNot=false)and(
        (('A'<=c1)and(c1<='Z')and(ord(c1)+$20=ord(c2))) or
        (('a'<=c1)and(c1<='z')and(ord(c1)-$20=ord(c2))) )then result:=true
      else result:=false;
   end;
begin
   result:=0;
   LenStr:=length(Str);
   LenBe:=length(BeReplace);
   if LenBe<=0 then exit;
   s:='';
   i:=1;
   while i<=LenStr do
   begin
      if CompChar(Str[i],BeReplace[1],CaseOrNot) then
      begin
         j:=2;
         while (j<=LenBe)and(i+j-1<=LenStr) do
         begin
            if not CompChar(Str[i+j-1],BeReplace[j],CaseOrNot) then break;
            inc(j);
         end;
         if j>LenBe then
         begin
            s:=s+WantToReplace;
            inc(i,LenBe-1);
         end
         else s:=s+Str[i];
      end
      else s:=s+Str[i];
      inc(i);
   end;
   Str:=s;
end;

procedure wait(ticks:dword);
var
   t:dword;
begin
   t:=gettickcount;
   while gettickcount-t<ticks do application.ProcessMessages;
end;


procedure ShowMessage2(msg:string);
begin
   messagedlg(msg,mtconfirmation,[mbok],0);
end;

end.

⌨️ 快捷键说明

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