by Khursheed_Siddiqui (3 Submissions)
Category: Coding Standards
Compatability: Visual Basic 5.0
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (4 Votes)
One line of code will tell you if you are connected to LAN or WAN(Internet).
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