Hi.
I used the function below (from the WWW).
It uses GetHostname in one of the paths, which you might find useful for
distinguishing the IP addresses.
Raymond
---
Dr. Raymond Kennington
function GetIPAddress(var IPAddress : String) : Boolean;
type
pu_long = ^u_long;
var
varTWSAData : TWSAData;
varPHostEnt : PHostEnt;
varTInAddr : TInAddr;
NameBuf : Array[0..255] of AnsiChar;
begin
Result := False;
try
try
if WSAStartup($101,varTWSAData) <> 0 then
begin
IPAddress := 'Getting IP Address: No Startup'
end
else
begin
GetHostname(NameBuf, SizeOf(NameBuf));
varPHostEnt := GetHostByName(NameBuf);
varTInAddr.S_addr := u_long(pu_long(varPHostEnt^.h_addr_list^)^);
IPAddress := inet_ntoa(varTInAddr);
Result := True;
end;
except
IPAddress := 'Getting IP Address: n/a';
end;
finally
WSACleanup();
end;
{$IFDEF TESTING}
ShowMessage('IP Address: ' + IPAddress);
{$ENDIF}
end;
--
To unsubscribe or change your settings for TWSocket mailing list
please goto http://lists.elists.org/cgi-bin/mailman/listinfo/twsocket
Visit our website at http://www.overbyte.be