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

📄 untglobal.pas

📁 实现了:自动锁屏
💻 PAS
字号:
unit untGlobal;

interface
uses SysUtils, StrUtils, IdBaseComponent, IdComponent, IdTCPConnection, IdTCPClient, IdHTTP;

Type
  TUrl = record
    Server: string;
    Port: integer;
    Url: string;
  end;

  TUser = record
    Uid: integer;
    UserName: string;
    Password: string;
    Sex: integer;
    Age: integer;
    Province: string;
    City: string;
    Level: string;
    Score: integer;
    RegDate: string;
    LastLogin: string;
    LoginTimes: integer;
    TipsType: string;
  end;
{ID int identity,
UserID varchar(20),
Title varchar(20),
Content varchar(2000),	--提醒内容
Player varchar(20),		--角色(MS Agent) 当该值=self时,为自定义“动作”
Action varchar(20),		--动作类型 当Player=self时,动作有:Power Off/Lock Desttop
Notify_Time datetime,
Notify_Type int,		--提醒类型 0:不提醒;1:日循环;2:周循环;3:月循环;4:一次性的
Flag bit				--提醒标志位 0:未提醒;1:已提醒  }
  PNotify = ^TNotify;
  TNotify = record
    ID: integer;
    UserID: integer;
    Title: string;
    Content: string;
    Player: string;
    Action: string;
    Notify_Time: TDateTime;
    Notify_Type: integer;
    Flag: integer;
  end;

  var
    mUser: TUser;
    mUrl: TUrl;

  function GetStr(const Source, Key: string): string;
  function GetXml(Action, User, Pwd: String): String;

  function StrToHexStr(const S:string):string;
  function HexStrToStr(const S:string):string;
  function XorStr(const S:string):string;
  function EncodePwd(const S:string):string;
  function DecodePwd(const S:string):string;
implementation

function GetStr(const Source, Key: string): string;
var
  s: string;
  i: integer;
begin
  i := Pos(Key, Source);
  if i < 1 then exit;

  s := Source;
  Delete(s, 1, i + Length(Key) - 1);

  i := Pos('&', s);
  if i < 1 then
  begin
    Result := s;
  end
  else
  begin
    Result := Copy(s, 1, i - 1)
  end;
end;

function GetXml(Action, User, Pwd: String): String;
var
  Http: TIdHttp;
begin
  try
    Http := TIdHttp.Create(nil);
    Result := Http.Get(Format('%s&1=1&action=%s&uid=%s&pwd=%s', [mUrl.Url, Action, User, Pwd]));
  finally
    Http.Free;
  end;
  
  Result := UTF8Decode(Result);
  if LeftStr(Result, 1) = '?' then Delete(Result, 1, 1);

  Result := StringReplace(Result, 'utf-8', 'gb2312', [rfReplaceAll]);
end;

function StrToHexStr(const S:string):string;
//字符串转换成16进制字符串
var
  I:Integer;
begin
  for I:=1 to Length(S) do
  begin
    if I=1 then
      Result:=IntToHex(Ord(S[1]),2)
    else Result:=Result+IntToHex(Ord(S[I]),2);
  end;
end;

function HexStrToStr(const S:string):string;
//16进制字符串转换成字符串
var
  t:Integer;
  ts:string;
  M,Code:Integer;
begin
  t:=1;
  Result:='';
  while t<=Length(S) do
  begin
    while not (S[t] in ['0'..'9','A'..'F','a'..'f']) do
      inc(t);
    if (t+1>Length(S))or(not (S[t+1] in ['0'..'9','A'..'F','a'..'f'])) then
      ts:='$'+S[t]
    else
      ts:='$'+S[t]+S[t+1];
    Val(ts,M,Code);
    if Code=0 then
      Result:=Result+Chr(M);
    inc(t,2);
  end;
end;

function XorStr(const S:string):string;
//异或字符串
const
  aXorChar:array [0..2] of Byte =(3,9,15);  //可以多写几个 ,这里用3个做示范
var
  I:Integer;
begin
  SetLength(Result,Length(S));
  for I:=1 to Length(S) do
  begin
    Result[I]:=Char(Ord(S[I]) Xor aXorChar[I mod (High(aXorChar)+1)]);
  end;
end;

function EncodePwd(const S:string):string;
//字符串加密
begin
  Result:=StrToHexStr(XorStr(S));
end;

function DecodePwd(const S:string):string;
//字符串解密
begin
  Result:=XorStr(HexStrToStr(S));
end;

end.

⌨️ 快捷键说明

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