That need is so frequent that it might be worth adding to the Synapse
library. While looking around for where such function might fit in best, I
wasn't sure, but thought the SynaMisc unit might be appropriate. In that
case, the function might be rewritten so it's use, and output
(comma-delimited instead of TStrings lines) looks more like the GetDNS()
function in that unit:
[ I've tried to write this code as Lukas would... ]
function GetLocalIPs : string; // or GetLocalIPaddresses ...
var
TcpSock : TTCPBlockSocket;
ipList : TStringList;
begin
ipList := TStringList.Create;
try
TcpSock := TTCPBlockSocket.create;
try
TcpSock.ResolveNameToIP(TcpSock.LocalName, ipList);
result := ReplaceString(trim(ipList.Text), sLineBreak, ','); // trim
needed as there will be at least one trailing line break...
finally
TcpSock.Free;
end;
finally
ipList.Free;
end;
end;
////////
By the way, here's a proposed alteration for the Windows section of the
GetDNS() function. On most computers here, that function always returns an
empty string. The following modifications match the DNS output of the
ipconfig command line program. [Note: I'm still one version back on the
Synapse library; haven't caught up on work; some of the following lines
_might_ have changed in the meantime.]
begin
Result := GetDNSbyIpHlp;
if Result = '...' then
if Win32Platform = VER_PLATFORM_WIN32_NT then
begin
Result := ReadReg(NTdyn, 'NameServer');
if result = '' then
Result := ReadReg(NTfix, 'NameServer');
if result = '' then // <-- ADDED
Result := ReadReg(NTfix, 'DhcpNameServer'); // <-- ADDED
Result := ReplaceString(trim(Result), ' ', ','); // <-- ADDED // NT
Registry has addresses space-delimited, but GetDNS() is defined as returning
comma-delimited entries
end
else
Result := ReadReg(W9xfix, 'NameServer');
end;
-------------------------------------------------------------------------
This SF.net email is sponsored by the 2008 JavaOne(SM) Conference
Don't miss this year's exciting event. There's still time to save $100.
Use priority code J8TL2D2.
http://ad.doubleclick.net/clk;198757673;13503038;p?http://java.sun.com/javaone
_______________________________________________
synalist-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/synalist-public