How can I access netstat-like Ethernet statistics from a Windows program

前端 未结 7 1992
臣服心动
臣服心动 2020-12-03 16:11

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

Interface Statistics

                       Received            Sent
         


        
7条回答
  •  时光取名叫无心
    2020-12-03 16:45

    The WMI will provide those readings:

    SELECT * FROM Win32_PerfFormattedData_Tcpip_IP
    SELECT * FROM Win32_PerfFormattedData_Tcpip_TCP
    SELECT * FROM Win32_PerfFormattedData_Tcpip_UDP
    SELECT * FROM Win32_PerfFormattedData_Tcpip_ICMP
    SELECT * FROM Win32_PerfFormattedData_Tcpip_Networkinterface
    

    These classes are available on Windows XP or newer. You may have to resign to the matching "Win32_PerfRawData" classes on Windows 2000, and do a little bit more of math before you can display the output.

    Find documentation on all of them in the MSDN.

提交回复
热议问题