It uses the GetIfEntry() from IPHLAPI.DLL - I remember I took the code a while ago from somewhere and change it slightly. Now I just noticed there is a GetIfEntry2() that supports ULONG64 return values in MIB_IF_ROW2 structure, that might be quite useful as the other one only supported DWORDs.
Thanks... I found another method as well in my looking. I am going to play around with both to see which is the most efficient as performance counters definitely are not.
I believe the GetIfEntry() entry method is used by Task Manager as well, for it's Network tab, it seems to be very low on resources. I couldn't even find any performance counters to read the number of transfered bytes.
hey this is viv here ..........thanks for your worthy code, i want to write code to calculate the total bytes sent and received for the whole day and to store that data in a database as a record of it.
Then you can probably use some of my code and put it in a service program - no idea how to write one, although there are tools out there that can make any app into a service, but obviously your app won't respond properly to service calls like Stop and it will get simply killed...
Would you mind sharing your code? I am trying to utilize a less cpu intensive method of calculating network utilization than performance counters.
ReplyDeleteNo problem, see the link in the post.
ReplyDeleteIt uses the GetIfEntry() from IPHLAPI.DLL - I remember I took the code a while ago from somewhere and change it slightly. Now I just noticed there is a GetIfEntry2() that supports ULONG64 return values in MIB_IF_ROW2 structure, that might be quite useful as the other one only supported DWORDs.
http://msdn.microsoft.com/en-us/library/aa365939(VS.85).aspx
http://msdn.microsoft.com/en-us/library/aa365941(VS.85).aspx
If you do anything on that, please do share.
Thanks... I found another method as well in my looking. I am going to play around with both to see which is the most efficient as performance counters definitely are not.
ReplyDeleteI believe the GetIfEntry() entry method is used by Task Manager as well, for it's Network tab, it seems to be very low on resources. I couldn't even find any performance counters to read the number of transfered bytes.
ReplyDeleteThanks for this! Exactly what I needed to look at after fiddling with performancecounters that only do an unreliable speed grab.
ReplyDeleteThanks David, if you happen to enhance it to work with ULONG64s, please do share.
ReplyDeletehey this is viv here ..........thanks for your worthy code, i want to write code to calculate the total bytes sent and received for the whole day and to store that data in a database as a record of it.
ReplyDeleteif u could send a mail to me here is my email id.
ReplyDeletevivmoney13@gmail.com
Then you can probably use some of my code and put it in a service program - no idea how to write one, although there are tools out there that can make any app into a service, but obviously your app won't respond properly to service calls like Stop and it will get simply killed...
ReplyDelete