Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleSee if the network is connected using RAS
DescriptionThis example shows how to see if the network is connected using RAS in Visual Basic 6. It uses the RasEnumConnections API function to enumerate the current network connections.
KeywordsRAS, network, connected, connection
CategoriesSoftware Engineering
 
Thanks to Theodore Fattaleh.

Use the RasEnumConnections API function to enumerate the current network connections.

 
Private Sub Command1_Click()
Dim ras_conn_info(255) As RASCONN95
Dim buf_size As Long
Dim i As Long
Dim num_connections As Long
Dim conn_name As String

    txtResults.Text = ""

    ras_conn_info(0).dwSize = RASCONN95_SIZE
    buf_size = 256 * ras_conn_info(0).dwSize
    RasEnumConnections ras_conn_info(0), buf_size, _
        num_connections
    For i = 0 To num_connections - 1
        conn_name = StrConv(ras_conn_info(i).szEntryName(), _
            vbUnicode)
        conn_name = Left$(conn_name, InStr(conn_name, _
            Chr$(0)) - 1)
        If Len(conn_name) > 0 Then
            txtResults.Text = txtResults.Text & _
                "Connected to " & conn_name & vbCrLf
        End If
    Next i

    txtResults.Text = txtResults.Text & "Done"
End Sub
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated