Need to detect local IP address under FireMonkey3. In VCL version, I have been using unit WinSock with methods for it
WSAStartup(...)
gethostname(...)
One limitation: don't need to use any third-party library. I am porting ASTA components to FireMonkey3 platform, and don't want to do dependencies among components.
If you need a cross-platform solution try using Indy and the TIdStack.AddLocalAddressesToList method included in the IdStack unit
Try this sample
var
AAddresses: TStrings;
begin
AAddresses := TStringList.Create;
try
TIdStack.IncUsage;
try
GStack.AddLocalAddressesToList(AAddresses);
finally
TIdStack.DecUsage;
end;
if AAddresses.Count > 0 then
//do something
finally
AAddresses.Free;
end;
end;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With