使用Delphi获取默认网关
有谁知道如何在 Delphi 2010 应用程序中获取默认网关?我找到了一些 Windows 函数,例如 GetAdaptersAddresses
,但我不知道如何使用它。
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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在 Windows XP 及更高版本上,使用 GetAdaptersAddresses 而不是 GetAdaptersInfo。
有一组函数实现 IP Helper API。请参阅delphi网页Magenta Systems
编辑:
来自Remok 评论:
如果仅配置了 IPv6 地址,则 GetAdaptersInfo 返回 ERROR_NO_DATA 。这就是 MSDN 建议使用 GetAdapterAddresses 的原因。
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.
您调用
GetAdaptersInfo()
。 MSDN 文档包含一个全面的示例如何称呼它。You call
GetAdaptersInfo()
. The MSDN documentation contains a comprehensive example of how to call it.