[英]How to get Received & Sent Network Bytes per second For a process (input: process id or handle) in C++ for Windows?
I need to get network information per process just like in resource monitor. 我需要像资源监视器一样获取每个进程的网络信息。 I need to find the received bytes/s & sent bytes/s.
我需要找到收到的字节/秒和发送的字节/秒。
I tried to get it using Win32_PerfRawData_PerfProc_Process class. 我试图使用Win32_PerfRawData_PerfProc_Process类来获取它。 But it gives IO, file bytes in addition to network details.
但除了网络细节之外,它还提供IO,文件字节。
I tried to get details using Win32_PerfRawData_Tcpip_NetworkInterface class. 我试图使用Win32_PerfRawData_Tcpip_NetworkInterface类获取详细信息。 But it gives details per Network interface.
但它提供了每个网络接口的详细信息
Then I tried to use GetTcpStatistics function. 然后我尝试使用GetTcpStatistics函数。 For that MIB_IPSTATS has been used.
因为已经使用了MIB_IPSTATS。 MIB_IPSTATS shows cumulative results for entire process.
MIB_IPSTATS显示整个过程的累积结果。
You might try looking into Performance Counters. 您可以尝试查看性能计数器。
https://msdn.microsoft.com/en-us/library/windows/desktop/aa373083(v=vs.85).aspx https://msdn.microsoft.com/en-us/library/windows/desktop/aa373083(v=vs.85).aspx
Here is a code project example of getting network speed using performance counters. 这是使用性能计数器获取网络速度的代码项目示例。 It is in c# but you should be able to translate to c++.
它在c#中,但您应该能够转换为c ++。
http://www.codeproject.com/Articles/6259/Monitoring-network-speed ' http://www.codeproject.com/Articles/6259/Monitoring-network-speed '
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.