DUN (Dial-Up Networking) Statistics
Posted: 2002-06-01
By: ArchiveBot
Viewed: 58
Filed Under:
No attachments for this post
Dial up networking (or RAS) statistics' availability differs depending on the windows platform. In windows 95 and 98 you can access the statistics via the Dyn_Data section of the registry. For windows NT you have to use one of the performance monitoring techniques, and for windows 2000 you probably can use the performance monitoring techniques also, but you can use the new RAS methods.
If you think that is code can be voted then please rate this... http://munim.cjb.net
Original Author: Munim.VIP
API Declarations
Public Type VBRasStats95
BytesXmited As Long
BytesRcved As Long
FramesXmited As Long
FramesRcved As Long
CrcErr As Long
TimeoutErr As Long
AlignmentErr As Long
HardwareOverrunErr As Long
FramingErr As Long
BufferOverrunErr As Long
Runts As Long
TotalBytesXmited As Long
TotalBytesRcved As Long
ConnectSpeed As Long
End Type
Public Const HKEY_DYN_DATA = &H80000006
Public Const KEY_READ = &H20019
Public Declare Function RegQueryValue _
Lib "advapi32.dll" Alias "RegQueryValueExA" _
(ByVal hKey As Long, ByVal lpValueName As String, _
ByVal lpReserved As Long, lpType As Long, _
lpData As Any, lpcbData As Long) As Long
Public Declare Function RegCloseKey _
Lib "advapi32.dll" (ByVal hKey As Long) As Long
Public Declare Function RegOpenKeyEx _
Lib "advapi32.dll" Alias "RegOpenKeyExA" _
(ByVal hKey As Long, ByVal lpSubKey As String, _
ByVal ulOptions As Long, ByVal samDesired As Long, _
phkResult As Long) As Long
Code
Function VBGetRasStats95(clsVBRasStats As VBRasStats95) As Long
Dim hKey As Long, rtn As Long, lngLen As Long, lResult As Long
On Error GoTo StatErrorHandler
lResult = RegOpenKeyEx(HKEY_DYN_DATA, "PerfStatsStatData", _
0&, KEY_READ, hKey)
With clsVBRasStats
lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterBuffer", _
0&, ByVal 0&, .BufferOverrunErr, lngLen)
lResult = lResult Or rtn: lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterBytesRecvd", _
0&, ByVal 0&, .BytesRcved, lngLen)
lResult = lResult Or rtn: lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterBytesXmit", _
0&, ByVal 0&, .BytesXmited, lngLen)
lResult = lResult Or rtn: lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterConnectSpeed", _
0&, ByVal 0&, .ConnectSpeed, lngLen)
lResult = lResult Or rtn: lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterCRC", _
0&, ByVal 0&, .CrcErr, lngLen)
lResult = lResult Or rtn: lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterAlignment", _
0&, ByVal 0&, .AlignmentErr, lngLen)
lResult = lResult Or rtn: lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterFramesRecvd", _
0&, ByVal 0&, .FramesRcved, lngLen)
lResult = lResult Or rtn: lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterFramesXmit", _
0&, ByVal 0&, .FramesXmited, lngLen)
lResult = lResult Or rtn: lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterFraming", _
0&, ByVal 0&, .FramingErr, lngLen)
lResult = lResult Or rtn: lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterOverrun ", _
0&, ByVal 0&, .HardwareOverrunErr, lngLen)
lResult = lResult Or rtn: lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterRunts", _
0&, ByVal 0&, .Runts, lngLen)
lResult = lResult Or rtn: lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterTimeout", _
0&, ByVal 0&, .TimeoutErr, lngLen)
lResult = lResult Or rtn: lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterTotalBytesRecvd", _
0&, ByVal 0&, .TotalBytesRcved, lngLen)
lResult = lResult Or rtn: lngLen = 4
rtn = RegQueryValue(hKey, "Dial-Up AdapterTotalBytesXmit", _
0&, ByVal 0&, .TotalBytesXmited, lngLen)
lResult = lResult Or rtn
End With
StatErrorHandler:
RegCloseKey hKey
VBGetRasStats95 = lResult
End Function
Comments on this post
No comments have been added for this post.
You must be logged in to make a comment.