'Вот код модуля, в зависимости от операционной системы, используются и соответствующие процедуры... Option Explicit Private Declare Function RasGetConnectionStatistics Lib "rasapi32.dll" (ByVal hRasConn As Long, lpStatistics As RASSTATS2000) As Long Public Type RASSTATS2000 dwSize As Long dwBytesXmited As Long 'The number of bytes transmitted through this connection or link. dwBytesRcved As Long 'The number of bytes received through this connection or link. dwFramesXmited As Long 'The number frames transmitted through this connection or link. dwFramesRcved As Long 'The number of frames received through this connection or link. dwCrcErr As Long 'The number of cyclic redundancy check (CRC) errors on this connection or link. dwTimeoutErr As Long 'The number of timeout errors on this connection or link. dwAlignmentErr As Long 'The number of alignment errors on this connection or link. dwHardwareOverrunErr As Long 'The number of hardware overrun errors on this connection or link. dwFramingErr As Long 'The number of framing errors on this connection or link. dwBufferOverrunErr As Long 'The number of buffer overrun errors on this connection or link. dwCompressionRatioIn As Long 'The compression ratio for the data being received on this connection or link. dwCompressionRatioOut As Long 'The compression ratio for the data being transmitted on this connection or link. dwBps As Long 'The speed of the connection or link, in bits per second. dwConnectDuration As Long 'The amount of time, in milliseconds, that the connection or link has been connected. End Type Public Type VBRasStats95 BytesXmited As Long 'The number of bytes transmitted through this connection or link. BytesRcved As Long 'The number of bytes received through this connection or link. FramesXmited As Long 'The number frames transmitted through this connection or link. FramesRcved As Long 'The number of frames received through this connection or link. CrcErr As Long 'The number of cyclic redundancy check (CRC) errors on this connection or link. TimeoutErr As Long 'The number of timeout errors on this connection or link. AlignmentErr As Long 'The number of alignment errors on this connection or link. HardwareOverrunErr As Long 'The number of hardware overrun errors on this connection or link. FramingErr As Long 'The number of framing errors on this connection or link. BufferOverrunErr As Long 'The number of buffer overrun errors on this connection or link. Runts As Long TotalBytesXmited As Long TotalBytesRcved As Long ConnectSpeed As Long 'The amount of time, in milliseconds, that the connection or link has been connected. End Type Public Function VBRasGetStat2000(hRasConn As Long, myStats As RASSTATS2000) As Long myStats.dwSize = Len(myStats) VBRasGetStat2000 = RasGetConnectionStatistics(hRasConn, myStats) End Function Public Function VBRasGetStat9x(clsVBRasStats As VBRasStats95) As Long Dim hKey As Long, rtn As Long, lngLen As Long, lResult As Long On Error GoTo er lResult = RegOpenKeyEx(HKEY_DYN_DATA, "PerfStats\StatData", 0&, &H7, hKey) With clsVBRasStats lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\Buffer", 0&, ByVal 0&, .BufferOverrunErr, lngLen) lResult = lResult Or rtn: lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\BytesRecvd", 0&, ByVal 0&, .BytesRcved, lngLen) lResult = lResult Or rtn: lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\BytesXmit", 0&, ByVal 0&, .BytesXmited, lngLen) lResult = lResult Or rtn: lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\ConnectSpeed", 0&, ByVal 0&, .ConnectSpeed, lngLen) lResult = lResult Or rtn: lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\CRC", 0&, ByVal 0&, .CrcErr, lngLen) lResult = lResult Or rtn: lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\Alignment", 0&, ByVal 0&, .AlignmentErr, lngLen) lResult = lResult Or rtn: lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\FramesRecvd", 0&, ByVal 0&, .FramesRcved, lngLen) lResult = lResult Or rtn: lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\FramesXmit", 0&, ByVal 0&, .FramesXmited, lngLen) lResult = lResult Or rtn: lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\Framing", 0&, ByVal 0&, .FramingErr, lngLen) lResult = lResult Or rtn: lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\Overrun", 0&, ByVal 0&, .HardwareOverrunErr, lngLen) lResult = lResult Or rtn: lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\Runts", 0&, ByVal 0&, .Runts, lngLen) lResult = lResult Or rtn: lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\Timeout", 0&, ByVal 0&, .TimeoutErr, lngLen) lResult = lResult Or rtn: lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\TotalBytesRecvd", 0&, ByVal 0&, .TotalBytesRcved, lngLen) lResult = lResult Or rtn: lngLen = 4 rtn = RegQueryValueEx(hKey, "Dial-Up Adapter\TotalBytesXmit", 0&, ByVal 0&, .TotalBytesXmited, lngLen) lResult = lResult Or rtn End With Exit Function er: Call RegCloseKey(hKey) Call MsgBox(GetINI("Msg", "m14", vbNullString), , "VBRasGetStat9x") End Function
Ответить
|