Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get default gateway using Delphi

Does anyone know how to get the default gateway in a Delphi 2010 app? I have found some windows functions like GetAdaptersAddresses, but I dont know how to use it.

like image 225
Rafael Colucci Avatar asked Nov 21 '25 22:11

Rafael Colucci


1 Answers

On Windows XP and later Use the GetAdaptersAddresses instead of GetAdaptersInfo.
There is a set of functions implementing IP Helper APIs. see the delphi web page at Magenta Systems

Edit:
from Remok comment : GetAdaptersInfo returns ERROR_NO_DATA if there is ONLY an IPv6 address configured. That's why MSDN recommends using GetAdapterAddresses.

like image 99
Najem Avatar answered Nov 23 '25 13:11

Najem



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!