From a96461ce233b4ebf71b2953fab331d5b716bc2d2 Mon Sep 17 00:00:00 2001
From: geby <geby@7c85be65-684b-0410-a082-b2ed4fbef004>
Date: Sun, 16 Jan 2022 14:03:45 +0000
Subject: [PATCH] new function GetLocalIPsFamily

git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@254 7c85be65-684b-0410-a082-b2ed4fbef004
---
 synamisc.pas | 19 +++++++++++++++++--
 1 file changed, 17 insertions(+), 2 deletions(-)

diff --git a/synamisc.pas b/synamisc.pas
index 2cfad8f..bb02a9b 100644
--- a/synamisc.pas
+++ b/synamisc.pas
@@ -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}