使用Delphi获取默认网关

发布于 2024-10-31 11:39:03 字数 105 浏览 3 评论 0原文

有谁知道如何在 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

活雷疯 2024-11-07 11:39:03

在 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.

情栀口红 2024-11-07 11:39:03

您调用 GetAdaptersInfo()MSDN 文档包含一个全面的示例如何称呼它。

You call GetAdaptersInfo(). The MSDN documentation contains a comprehensive example of how to call it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文