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
This commit is contained in:
geby
2008-04-29 19:44:07 +00:00
parent c9ba9c85d9
commit 01ce14537b

View File

@ -1,9 +1,9 @@
{==============================================================================| {==============================================================================|
| Project : Ararat Synapse | 001.001.004 | | Project : Ararat Synapse | 001.002.000 |
|==============================================================================| |==============================================================================|
| Content: misc. procedures and functions | | Content: misc. procedures and functions |
|==============================================================================| |==============================================================================|
| Copyright (c)1999-2003, Lukas Gebauer | | Copyright (c)1999-2008, Lukas Gebauer |
| All rights reserved. | | All rights reserved. |
| | | |
| Redistribution and use in source and binary forms, with or without | | Redistribution and use in source and binary forms, with or without |
@ -33,7 +33,7 @@
| DAMAGE. | | DAMAGE. |
|==============================================================================| |==============================================================================|
| The Initial Developer of the Original Code is Lukas Gebauer (Czech Republic).| | 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. | | All Rights Reserved. |
|==============================================================================| |==============================================================================|
| Contributor(s): | | Contributor(s): |
@ -95,6 +95,9 @@ function GetDNS: string;
working only on windows!} working only on windows!}
function GetIEProxy(protocol: string): TProxySetting; function GetIEProxy(protocol: string): TProxySetting;
{:Return all known IP addresses on local system. Addresses are divided by comma.}
function GetLocalIPs: string;
implementation implementation
{==============================================================================} {==============================================================================}
@ -257,14 +260,19 @@ const
begin begin
Result := GetDNSbyIpHlp; Result := GetDNSbyIpHlp;
if Result = '...' then if Result = '...' then
begin
if Win32Platform = VER_PLATFORM_WIN32_NT then if Win32Platform = VER_PLATFORM_WIN32_NT then
begin begin
Result := ReadReg(NTdyn, 'NameServer'); Result := ReadReg(NTdyn, 'NameServer');
if result = '' then if result = '' then
Result := ReadReg(NTfix, 'NameServer'); Result := ReadReg(NTfix, 'NameServer');
if result = '' then
Result := ReadReg(NTfix, 'DhcpNameServer');
end end
else else
Result := ReadReg(W9xfix, 'NameServer'); Result := ReadReg(W9xfix, 'NameServer');
Result := ReplaceString(trim(Result), ' ', ',');
end;
end; end;
{$ENDIF} {$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. end.