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;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.