Recently I encountered a very troublesome problem and I have never found a good solution.
Problem:
You must obtain both the NIC utilization and the NIC connection speed.
Solution:
You can use the PDH library to obtain the network adapter's transmission rate and other information.
Obtain the network adapter connection speed
1. Use WMI to query
2. Use the IP helper Interface
3. Use the NetMonitor Interface
4. Check the Registry
The trouble here is that if we get the utilization through PDH, we can only get the static information of the network interface instance only by the name of the network interface instance. However, we cannot use this name for ing. For example, the NIC name is Intel (r) 100/1000, but the Instance name obtained from PDH is Intel [R] 100_1000.
I have a trouble in using NetMonitor to calculate the utilization. I don't know if there is any better way.