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

📄 sys32dll.dpr

📁 SPIG1.1.rar SPIG接口协议
💻 DPR
📖 第 1 页 / 共 2 页
字号:
library Sys32DLL;

{ Important note about DLL memory management: ShareMem must be the
  first unit in your library's USES clause AND your project's (select
  Project-View Source) USES clause if your DLL exports any procedures or
  functions that pass strings as parameters or function results. This
  applies to all strings passed to and from your DLL--even those that
  are nested in records and classes. ShareMem is the interface unit to
  the BORLNDMM.DLL shared memory manager, which must be deployed along
  with your DLL. To avoid using BORLNDMM.DLL, pass string information
  using PChar or ShortString parameters. }

uses
  ShareMem,
  Forms,
  Classes,
  Windows,
  SysUtils,
  Registry,
  ActiveX,
  Math,
  ShellAPI;

{$R *.res}

var
 Reg : TRegistry;

{
  Function ID=1000
  检测IP地址合法性
}
function CheckIP(IP:string):integer;stdcall;
var
  i,j,k:integer;
  s,t:string;
begin
  Result:=0; k:=0; s:=IP;
  // 检查输入字符串是否由数字和'.'组成
  for i:=1 to Length(s) do
    if (not (s[i] in ['0'..'9'])) and (s[i]<>'.')
      then begin
        Result:=1001;
        Exit;
      end;
  i:=Pos('.',s);
  { 检测IP地址 }
  while i>0 do
    begin
      t:=Copy(s,1,i-1);
      try
        j:=StrToInt(t);
        if (j<0) or (j>255)
          then begin
            Result:=1002;
            Exit;
          end
          else Inc(k);
      except
        Result:=1003;
      end;
      s:=Copy(s,i+1,Length(s)-i);
      i:=Pos('.',s);
    end;
  if k<>3 then Result:=1004;
end;
 
{ 格式化字符串,Len必须为2的倍数 将整型转换为十六进制}
function FmtChar(const Source:LongWord;Len:byte):string;stdcall;
var
  i:Integer;
  j:byte;
  s:string;
begin
  Result:='';
  { 转换整数到其十六进制编码,以Len长度为标准 }
  s:=IntToHex(Source,Len);
  for i:=1 to Length(s) do
    begin
      { 每两个字符转换为一个字节 }
      if i mod 2=0
        then begin
          j:=StrToInt('$'+s[i-1]+s[i]);
          Result:=Result+Char(j);
        end;
    end;
end;

//Informat Log function
procedure WriteLog(FileName:string;Context:string);stdcall;
var
  Tf:TextFile;
  i:integer;
  Ls:TStringList;
begin
  if Context=''
    then Exit;
  Ls:=TStringList.Create;
  AssignFile(Tf,FileName);
  try
    Ls.CommaText:=Context;
    try
      if FileExists(FileName) then Append(Tf)
        else ReWrite(Tf);
      for i:=0 to Ls.Count-1 do
           begin
            WriteLn(Tf,FormatDateTime('dddddd hh:mm:ss',Now)+' '+Ls.Strings[i]);
            WriteLn(Tf);
           end;
    except
    end;
  finally
    CloseFile(Tf);
    Ls.Free;
  end;
end;

//读取本地主机IP//
function GetLocatIPAddr:string;stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', False)
      then Result:=Reg.ReadString('LocatIPAddr');
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//设置本地主机IP//
procedure SetLocatIPAddr(Value:String);stdcall;
begin
 Reg:=TRegistry.Create;
 try
  Reg.RootKey:=HKEY_LOCAL_MACHINE;
  if Reg.OpenKey('\Software\SGIPServerPar', True)
    then Reg.WriteString('LocatIPAddr',Value);
 finally
   Reg.CloseKey;
   Reg.Free;
 end;
end;

//读取远程IP//
function GetRemoteIPAddr:string;stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', False)
      then Result:=Reg.ReadString('RemoteIPAddr');
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//设置远程IP//
procedure SetRemoteIPAddr(Value:String);stdcall;
begin
 Reg:=TRegistry.Create;
 try
  Reg.RootKey:=HKEY_LOCAL_MACHINE;
  if Reg.OpenKey('\Software\SGIPServerPar', True)
    then Reg.WriteString('RemoteIPAddr',Value);
 finally
   Reg.CloseKey;
   Reg.Free;
 end;
end;

//读取本地主机端口//
function GetLocatHostPort:Integer;stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', False)
      then Result:=Reg.ReadInteger('LocatHostPort');
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//读取远程主机端口
function GetRemoteHostPort:Integer;stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', False)
      then Result:=Reg.ReadInteger('RemoteHostPort');
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//读取本地主机接收端口//
function GetRecvHostPort:Integer;stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', False)
      then Result:=Reg.ReadInteger('RecvHostPort');
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//读取远程主机接收端口
procedure SetRecvHostPort(Value:Integer);stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', True)
      then Reg.WriteInteger('RecvHostPort',Value);
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//设置本地主机端口//
procedure SetLocatHostPort(Value:integer);stdcall;
begin
 Reg:=TRegistry.Create;
 try
  Reg.RootKey:=HKEY_LOCAL_MACHINE;
  if Reg.OpenKey('\Software\SGIPServerPar', True)
    then Reg.WriteInteger('LocatHostPort',Value);
 finally
   Reg.CloseKey;
   Reg.Free;
 end;
end;

//设置远程主机端口//
procedure SetRemoteHostPort(Value:Integer);stdcall;
begin
 Reg:=TRegistry.Create;
 try
  Reg.RootKey:=HKEY_LOCAL_MACHINE;
  if Reg.OpenKey('\Software\SGIPServerPar', True)
    then Reg.WriteInteger('RemoteHostPort',Value);
 finally
   Reg.CloseKey;
   Reg.Free;
 end;
end;

//日志检测标志
function GetCurLogChk:Boolean;stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', False)
      then Result:=Reg.ReadBool('CurLogChk');
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//日志检测标志
procedure SetCurLogChk(Value:Boolean);stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', True)
      then Reg.WriteBool('CurLogChk',Value);
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//读取登陆用户名信息
function GetUserName:string;stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', False)
      then Result:=Reg.ReadString('UserName');
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//设置登陆用户名信息
procedure SetUserName(Value:string);stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', True)
      then Reg.WriteString('UserName',Value);
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//读取登陆口令信息
function GetPassWord:string;stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', False)
      then Result:=Reg.ReadString('PassWord');
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//设置登陆口令信息
procedure SetPassWord(Value:string);stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', True)
      then Reg.WriteString('PassWord',Value);
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//读取SP企业接入号
function GetSPNumber:string;stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', False)
      then Result:=Reg.ReadString('SPNumber');
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//设置SP企业接入号
procedure SetSPNumber(Value:string);stdcall;
begin
  Reg:=TRegistry.Create;
  try
    Reg.RootKey:=HKEY_LOCAL_MACHINE;
    if Reg.OpenKey('\Software\SGIPServerPar', True)
      then Reg.WriteString('SPNumber',Value);
  finally
    Reg.CloseKey;
    Reg.Free;
  end;
end;

//读取发送超时参数
function GetSendTimeOut:Integer;stdcall;
begin
  Reg:=TRegistry.Create;

⌨️ 快捷键说明

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