Results 1 to 2 of 2

Thread: what is wrong with that code

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Jul 2000
    Location
    didn't decide yet
    Posts
    222

    what is wrong with that code

    Code:
    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 x As RASCONN
        Dim stat As RAS_STATS
        Dim y As Long, z As Long
            
        x.dwSize = Len(x)
        y = x.dwSize
        
        Debug.Print y
        Debug.Print RasEnumConnections(VarPtr(x), VarPtr(y), VarPtr(z))
        Debug.Print z
        Debug.Print y
        Debug.Print StrConv(x.szEntryName, vbUnicode)
        Debug.Print StrConv(x.szDeviceType, vbUnicode)
        Debug.Print StrConv(x.szDeviceName, vbUnicode)
    
        'i m getting an error below it should return 0 do not know why 
        Debug.Print RasGetConnectionStatistics(x.hRasConn, VarPtr(stat))
        Debug.Print stat.dwBytesRcved
        
        
    End Sub

  2. #2
    Monday Morning Lunatic parksie's Avatar
    Join Date
    Mar 2000
    Location
    Mashin' on the motorway
    Posts
    8,169
    Since I couldn't test it earlier I didn't notice, but do this before you call the function:
    Code:
    stat.dwSize = Len(stat)
    I refuse to tie my hands behind my back and hear somebody say "Bend Over, Boy, Because You Have It Coming To You".
    -- Linus Torvalds

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