Results 1 to 3 of 3

Thread: logging network usage

  1. #1

    Thread Starter
    Registered User Olly's Avatar
    Join Date
    Apr 2001
    Location
    Switzerland
    Posts
    252

    Question logging network usage

    Hi!
    I'm currently making a program that needs to display the network usage, for example i would like to display the upload and download rate with two seperate progress bars. I've seen it in programs like ZoneAlarm but was trying in vain to find any information on how to receive that info. Is it in the registry or is there a special API call for it? I know that in win98 there used to be the registry folder "DynData" which contained that sort of information but there's nothing like that in win2k/xp. Any help would be appreciated.
    Last edited by Olly; Dec 8th, 2001 at 08:35 AM.

  2. #2

    Thread Starter
    Registered User Olly's Avatar
    Join Date
    Apr 2001
    Location
    Switzerland
    Posts
    252

    Thumbs up Found it out myself!

    Code:
    'Example created by Tolis Bekiaris ([email protected])
    Private Declare Function RasEnumConnections Lib "rasapi32" Alias "RasEnumConnectionsA" (ByVal lprasconn As Long, ByVal lpcb As Long, ByVal lpcConnections As Long) As Long
    Private Declare Function RasGetConnectionStatistics Lib "rasapi32" (ByVal hRasConn As Long, ByVal lpStatistics As Long) As Long
    Private Type RASCONN
        dwSize As Long
        hRasConn As Long
        szEntryName(0 To 256) As Byte
        szDeviceType(0 To 16) As Byte
        szDeviceName(0 To 128) As Byte
        pad As Byte
    End Type
    Private Type RAS_STATS
        dwSize As Long
        dwBytesXmited As Long
        dwBytesRcved As Long
        dwFramesXmited As Long
        dwFramesRcved As Long
        dwCrcErr As Long
        dwTimeoutErr As Long
        dwAlignmentErr As Long
        dwHardwareOverrunErr As Long
        dwFramingErr As Long
        dwBufferOverrunErr As Long
        dwCompressionRatioIn As Long
        dwCompressionRatioOut As Long
        dwBps As Long
        dwConnectDuration As Long
    End Type
    
    Private Sub Form_Load()
        Dim conn As RASCONN
        Dim stat As RAS_STATS
        Dim y As Long, z As Long
            
        conn.dwSize = Len(conn)
        y = conn.dwSize
        
        
        If RasEnumConnections(VarPtr(conn), VarPtr(y), VarPtr(z)) = 0 Then
            stat.dwSize = Len(stat)
            If RasGetConnectionStatistics(conn.hRasConn, VarPtr(stat)) = 0 Then
                Debug.Print stat.dwAlignmentErr
                Debug.Print stat.dwBps
                Debug.Print stat.dwBufferOverrunErr
                Debug.Print stat.dwBytesRcved
                Debug.Print stat.dwBytesXmited
                Debug.Print stat.dwCompressionRatioIn
                Debug.Print stat.dwCompressionRatioOut
                Debug.Print stat.dwConnectDuration
                Debug.Print stat.dwCrcErr
                Debug.Print stat.dwFramesRcved
                Debug.Print stat.dwFramesXmited
                Debug.Print stat.dwFramingErr
                Debug.Print stat.dwTimeoutErr
            End If
        End If
        
    End Sub

  3. #3
    Frenzied Member
    Join Date
    Dec 2000
    Posts
    1,195
    that wont work in NT..

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width