From 01ce14537bee28ad44cb80fcf54b0382ab045089 Mon Sep 17 00:00:00 2001 From: geby Date: Tue, 29 Apr 2008 19:44:07 +0000 Subject: [PATCH] Added GetLocalIPs helper function, fixed GetDNS function for DNS assigned by DHCP. git-svn-id: https://svn.code.sf.net/p/synalist/code/trunk@92 7c85be65-684b-0410-a082-b2ed4fbef004 --- synamisc.pas | 36 +++++++++++++++++++++++++++++++++--- 1 file changed, 33 insertions(+), 3 deletions(-) diff --git a/synamisc.pas b/synamisc.pas index 8b861a9..78ec9bc 100644 --- a/synamisc.pas +++ b/synamisc.pas @@ -1,9 +1,9 @@ {==============================================================================| -| Project : Ararat Synapse | 001.001.004 | +| Project : Ararat Synapse | 001.002.000 | |==============================================================================| | Content: misc. procedures and functions | |==============================================================================| -| Copyright (c)1999-2003, Lukas Gebauer | +| Copyright (c)1999-2008, Lukas Gebauer | | All rights reserved. | | | | Redistribution and use in source and binary forms, with or without | @@ -33,7 +33,7 @@ | DAMAGE. | |==============================================================================| | The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).| -| Portions created by Lukas Gebauer are Copyright (c) 2002-2003. | +| Portions created by Lukas Gebauer are Copyright (c) 2002-2008. | | All Rights Reserved. | |==============================================================================| | Contributor(s): | @@ -95,6 +95,9 @@ function GetDNS: string; working only on windows!} function GetIEProxy(protocol: string): TProxySetting; +{:Return all known IP addresses on local system. Addresses are divided by comma.} +function GetLocalIPs: string; + implementation {==============================================================================} @@ -257,14 +260,19 @@ const begin Result := GetDNSbyIpHlp; if Result = '...' then + begin if Win32Platform = VER_PLATFORM_WIN32_NT then begin Result := ReadReg(NTdyn, 'NameServer'); if result = '' then Result := ReadReg(NTfix, 'NameServer'); + if result = '' then + Result := ReadReg(NTfix, 'DhcpNameServer'); end else Result := ReadReg(W9xfix, 'NameServer'); + Result := ReplaceString(trim(Result), ' ', ','); + end; end; {$ENDIF} @@ -356,4 +364,26 @@ end; {==============================================================================} +function GetLocalIPs: string; +var + TcpSock: TTCPBlockSocket; + ipList: TStringList; +begin + Result := ''; + ipList := TStringList.Create; + try + TcpSock := TTCPBlockSocket.create; + try + TcpSock.ResolveNameToIP(TcpSock.LocalName, ipList); + Result := ipList.CommaText; + finally + TcpSock.Free; + end; + finally + ipList.Free; + end; +end; + +{==============================================================================} + end.