Detecting if connected to LAN or WAN
![Visual Basic 6, or VB Classic Visual Basic 6, or VB Classic](https://www.fortypoundhead.com//assets/img/icons/v7/vb6.png)
One line of code will tell you if you are connected to LAN or WAN(Internet).
Original Author: Khursheed_Siddiqui
Code
Private Declare Function IsNetworkAlive Lib "Sensapi.dll" (LPDFlags As Long) As Long
Private Const NETWORK_ALIVE_LAN = &H1 'net card connection
Private Const NETWORK_ALIVE_WAN = &H2 'RAS connection
Private Const NETWORK_ALIVE_AOL = &H4 'AOL
Private Sub Form_Load()
Dim tmp As Long
Dim ConnectionType As String
If IsNetworkAlive(tmp) = NETWORK_ALIVE_LAN Then
ConnectionType = "LAN"
ElseIf IsNetworkAlive(tmp) = NETWORK_ALIVE_WAN Then
ConnectionType = "WAN"
ElseIf IsNetworkAlive(tmp) = NETWORK_ALIVE_AOL Then
ConnectionType = "AOL"
Else
ConnectionType = "Could not Determine."
End If
Print
Print "Your connection type is: " & ConnectionType
End Sub
Loading Comments ...
Comments
No comments have been added for this post.
You must be logged in to make a comment.