Reputation: 329
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.
Upvotes: 3
Views: 3861
Reputation: 136441
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;
Upvotes: 9