Advertisement
2_2002-2004 Coding Standards #119936

Detecting if connected to LAN or WAN

One line of code will tell you if you are connected to LAN or WAN(Internet).

AI

Résumé par IA: This codebase represents a historical implementation of the logic described in the metadata. Our preservation engine analyzes the structure to provide context for modern developers.

Code source
original-source
Private Declare Function IsNetworkAlive Lib "Sensapi.dll" (LPDFlags As Long) As Long <BR>
Private Const NETWORK_ALIVE_LAN = &H1 'net card connection<BR>
Private Const NETWORK_ALIVE_WAN = &H2 'RAS connection<BR>
Private Const NETWORK_ALIVE_AOL = &H4 'AOL<BR>
Private Sub Form_Load()<BR>
 Dim tmp As Long<BR>
 Dim ConnectionType As String<BR>
 
 If IsNetworkAlive(tmp) = NETWORK_ALIVE_LAN Then<BR>
 ConnectionType = "LAN"<BR>
 ElseIf IsNetworkAlive(tmp) = NETWORK_ALIVE_WAN Then<BR>
 ConnectionType = "WAN"<BR>
 ElseIf IsNetworkAlive(tmp) = NETWORK_ALIVE_AOL Then<BR>
 ConnectionType = "AOL"<BR>
 Else<BR>
 ConnectionType = "Could not Determine."<BR>
 End If<BR>
 Print<BR>
 Print "Your connection type is: " & ConnectionType<BR>
 
 
End Sub
Commentaires originaux (3)
Récupéré via Wayback Machine