I have a problem when trying to detect the computers network connection status. Here is the code I have used:
Dim IsAvalible As String = My.Computer.Network.IsAvailable
If IsAvalible = True Then Label1.Text = "Connected" Else <code> <code>If IsAvalible = False Then</code> I <code> Label1.Text = &quot;Disconnected&quot;</code></code> End If [/ICODE] End If[/ICODE]
But for some even when the network is disconnected or the computers wifi is turned on I still get the result of "Connected". I think there something wrong with the code. Could someone help me please ? Thank You
PS. Im not sure how to use the ICODE Tagging thing, sorry
Thing is, if you are behind a router then you have always a network available.
try this instead:
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Int32, ByVal dwReserved As Int32) As Boolean
Public Shared Function IsConnectedToInternet() As Boolean
Dim Desc As Int32
Return InternetGetConnectedState(Desc, 0)
End Function