?? sys32dll.dpr
字號:
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 + -