如何使用 Win32_PerfRawData_Tcpip_NetworkInterface 类获取 C++ 中的当前带宽

发布于 2024-10-02 16:32:29 字数 135 浏览 1 评论 0原文

我想如何使用 Win32_PerfRawData_Tcpip_NetworkInterface 类来获取当前带宽。 我想从一开始就知道。我正在使用 xp,Microsoft Visual C++ 2005 Express Edition。我不知道如何操作。

I wanted to how to use Win32_PerfRawData_Tcpip_NetworkInterface class to get the current bandwidth.
I want to know from the begining. i'm using xp,Microsoft Visual C++ 2005 Express Edition.I'm not getting how to.

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

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

发布评论

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

评论(2

帥小哥 2024-10-09 16:32:29

您可能会发现使用 性能计数器 直接使用 API,而不是通过 WMI。 此处提供了分步说明。

创建查询并添加后
与之相反,请致电
PdhCollectQueryData 函数
检索所有当前原始数据
查询中的计数器。

许多计数器,例如费率计数器,
需要两个数据样本来计算
格式化的数据值。 PDH维持
当前样本的数据和
之前收集的样本。这
以下过程描述了如何
收集需要的计数器值
两个样本来计算可显示的
值。

这两个 API 都很复杂,没有简单的方法。

You may find it easier to get the required data using the Performance Counters API directly instead of going through WMI. Step by step instructions are here.

After creating a query and adding
counters to it, call the
PdhCollectQueryData function to
retrieve the current raw data for all
counters in the query.

Many counters, such as rate counters,
require two data samples to calculate
a formatted data value. PDH maintains
data for the current sample and the
previously collected sample. The
following procedure describes how to
collect counter values that require
two samples to calculate a displayable
value.

Both APIs are complex, there is no easy way here.

飘落散花 2024-10-09 16:32:29

您应该使用 *Win32_PerfFormattedData_Tcpip_NetworkInterface* 来代替,原始计数器需要在使用之前进行处理,这是一项艰巨的任务。

以下属性可能令人感兴趣:

BytesReceivedPerSec、BytesSentPerSec、CurrentBandwidth(用于计算利用率)、BytesTotalPerSec

You should use the *Win32_PerfFormattedData_Tcpip_NetworkInterface* instead, the Raw counter needs to be processed before used and thats a non-trivial task.

The following properties may be of interest:

BytesReceivedPerSec, BytesSentPerSec, CurrentBandwidth ( to calculate utilization) , BytesTotalPerSec

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