如何确定 PdhExpandWildCardPath 结果中的主要网络适配器?

发布于 2024-10-04 19:58:03 字数 345 浏览 0 评论 0原文

我的目标是使用 Windows 性能计数器 API 测量每秒接收的平均字节数。我的问题是,当有多个网络适配器时,我不知道哪一个是“主要”适配器(即用于 Internet 和 LAN 流量的适配器)。

我可以将“\Network Interface(*)\Bytes Received/sec”传递给 PdhExpandWildCardPath() 并获取列表,但该列表似乎按字母顺序排列,而不是按路由顺序排列。 PdhExpandWildCardPath() 返回的名称似乎与 WMI 函数使用的名称不同 - Pdh 似乎添加了“Packet Scheduler Miniport” - 所以即使我走了那条路,我也不知道如何将来自不同 API 的信息关联起来。

My goal is to measure the average Bytes received per second using the Windows performance counter API. My problem is that, when there are multiple network adapters, I don't know which one is the "primary" one (i.e. the one used for Internet and LAN traffic).

I can pass "\Network Interface(*)\Bytes Received/sec" to PdhExpandWildCardPath() and get a list back, but that list seems to be in alphabetical order, not routing order. And the names returned by PdhExpandWildCardPath() don't seem to be the same as the ones the WMI functions use -- Pdh seems to add "Packet Scheduler Miniport" -- so even if I went that route I'm not sure how to correlate the information from the different APIs.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(1

街道布景 2024-10-11 19:58:03

哪个网络适配器是“主要”是一个定性判断。计算机可能同时具有板载无线 802.11 和有线以太网适配器,其中任何一个在任何给定时间(甚至同时)都可以是主要适配器。

您可能必须使用 IP Helper API< /a> 来确定您更喜欢哪个并将其与 PerfMon 输出相关联。或者您可以选择活动最多的一个并将其称为主要的。这正是 PerfMon 无法做出的价值判断,因为这些统计数据对它来说是透明的。

Which network adapter is 'Primary' is a qualitative judgment. A computer might have both onboard wireless 802.11, and wired Ethernet adapters, either of which could be primary at any given time (or even at the same time).

You are probably going to have to use the IP Helper API to determine which you prefer and correlate that with the PerfMon ouput. or you could just pick the one with the most activity and call it primary. That's just the kind of value judgment that PerfMon cannot possibly make, as these stats are transparent to it.

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