vishal
vishal

Reputation: 91

how to use Win32_PerfRawData_Tcpip_NetworkInterface class to get the current bandwidth in C++

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.

Upvotes: 0

Views: 2803

Answers (2)

ROAR
ROAR

Reputation: 1324

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

Upvotes: 0

Steve Townsend
Steve Townsend

Reputation: 54178

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.

Upvotes: 1

Related Questions