new function GetLocalIPsFamily

git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@254 7c85be65-684b-0410-a082-b2ed4fbef004
This commit is contained in:
geby 2022-01-16 14:03:45 +00:00
parent 49454ea6e1
commit a96461ce23

View File

@ -64,6 +64,10 @@
{$WARN IMPLICIT_STRING_CAST_LOSS OFF}
{$ENDIF}
{$IFDEF NEXTGEN}
{$ZEROBASEDSTRINGS OFF}
{$ENDIF}
unit synamisc;
interface
@ -115,6 +119,10 @@ function GetDNS: string;
works only on windows!}
function GetIEProxy(protocol: string): TProxySetting;
{:Return all known IP addresses of required type on the local system. Addresses are divided by
comma/comma-delimited.}
function GetLocalIPsFamily(value: TSocketFamily): string;
{:Return all known IP addresses on the local system. Addresses are divided by
comma/comma-delimited.}
function GetLocalIPs: string;
@ -146,7 +154,7 @@ begin
for n := 0 to 5 do
begin
b := StrToIntDef('$' + MAC[n * 2 + 1] + MAC[n * 2 + 2], 0);
HexMac := HexMac + char(b);
HexMac := HexMac + AnsiChar(b);
end;
if IP = '' then
IP := cBroadcast;
@ -432,7 +440,7 @@ end;
{==============================================================================}
function GetLocalIPs: string;
function GetLocalIPsFamily(value: TSocketFamily): string;
var
TcpSock: TTCPBlockSocket;
ipList: TStringList;
@ -442,6 +450,8 @@ begin
try
TcpSock := TTCPBlockSocket.create;
try
if value <> SF_Any then
TcpSock.family := value;
TcpSock.ResolveNameToIP(TcpSock.LocalName, ipList);
Result := ipList.CommaText;
finally
@ -452,6 +462,11 @@ begin
end;
end;
function GetLocalIPs: string;
begin
Result := GetLocalIPsFamily(SF_Any);
end;
{==============================================================================}
{$IFDEF MSWINDOWS}