After much trial and error I finally figured out how to obtain the byte counts across the TCPIP connection(s). The following sample is provided in case some other poor soul needs a quick and dirty view.
Notes:
1. My workstation has three TCIP return values, but only the first one is what I want (last one never changes). Check the value in "objItem.Name".
2. There's a ton of other stats available, but I excluded from this sample. Let me know if you want additional data.
Public Type BytesSentReceived
BytesSent As Double
BytesReceived As Double
End Type
Sub Call_Sample()
Dim ByteCounts As BytesSentReceived
ByteCounts = Get_Bytes_Sent_Received
Debug.print "Sent: " & ByteCounts.BytesSent
Debug.print "Rcvd: " & ByteCounts.BytesReceived
End Sub
Function Get_Bytes_Sent_Received() As BytesSentReceived
Dim strComputer As String
Dim objWMIService
Dim colItems
Dim objItem
Dim ByteCounts As BytesSentReceived
'MsgBox "Get_Bytes_Sent_Received: find correct name to use..."
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfRawData_Tcpip_NetworkInterface", , 48)
For Each objItem In colItems
If objItem.Name <> "MS TCP Loopback interface" Then
'Debug.Print "-------------Win32_PerfRawData_Tcpip_NetworkInterface---------- "
'Debug.Print "Name: " & objItem.Name
'Debug.Print "BytesReceivedPersec: " & objItem.BytesReceivedPersec
'Debug.Print "BytesSentPersec: " & objItem.BytesSentPersec
ByteCounts.BytesReceived = objItem.BytesReceivedPersec
ByteCounts.BytesSent = objItem.BytesSentPersec
End If
Next
Get_Bytes_Sent_Received = ByteCounts
Set objItem = Nothing
Set colItems = Nothing
Set objWMIService = Nothing
End Function
"Have a great day today and a better day tomorrow!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.