我如何可以访问Windows程序的netstat类似以太网统计 [英] How can I access netstat-like Ethernet statistics from a Windows program

查看:216
本文介绍了我如何可以访问Windows程序的netstat类似以太网统计的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何访问以太网统计,从C / C ++ code例如的netstat -e

 接口统计                       发送接收字节21010071 15425579
单播数据包95512 94166
非单播包12510 7
丢弃0 0
错误3 0
未知协议0


解决方案

一个良好的开端为网统计将是的 GetIpStatistics在Windows IPHelper函数调用

有几个是可能更容易移植其他方法: -


  • SNMP。 SNMP需要在计算机上启用,但显然可以用于检索远程计算机也统计。

  • 管'的netstat的输出到您的应用程序,并从文本拆洗的值。

How can I access Ethernet statistics from C/C++ code like netstat -e?

Interface Statistics

                       Received            Sent

Bytes                      21010071        15425579
Unicast packets               95512           94166
Non-unicast packets           12510               7
Discards                          0               0
Errors                            0               3
Unknown protocols                 0

解决方案

A good place to start for network statistics would be the GetIpStatistics call in the Windows IPHelper functions.

There are a couple of other approaches that are possibly more portable:-

  • SNMP. Requires SNMP to be enabled on the computer, but can obviously be used to retrieve statistics for remote computers also.
  • Pipe the output of 'netstat' into your application, and unpick the values from the text.

这篇关于我如何可以访问Windows程序的netstat类似以太网统计的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆