Thanks for your prompt reply.
I tried systeminformation.network, but its returning true in both the cases.
I unhooked my laptop from docking station and tried with detaching the network cable also, still it SystemInformation.Network returns TRUE.
I don't know what is wrong or may be its a bug.
Anyway thanks for your help.
Do let me know if you can think of something else.
Oops, my apologies. SystemInformation.Network returns hardware information not connection information (it meets my uses for it but is not applicable to your question). I will right my wrong; here is a function that will do what you need (this is not my code, it comes from a post by Dean Slindee on Google Groups):
Public Function IsNetworkAvailable() As Boolean
Dim NAQuery As New SelectQuery("SELECT * FROM Win32_NetworkAdapterConfiguration()")
Dim NASearcher As New ManagementObjectSearcher(NAQuery)
Dim IsAvailable As Boolean = False
Dim IPEnabled As Boolean = False
Dim IPAddress() As String
Dim str As String
Try
Dim manObject As ManagementObject
For Each manObject In NASearcher.Get()
IPEnabled = CBool(manObject("IPEnabled"))
If IPEnabled Then
IPAddress = CType(manObject("IPAddress"), String())
If IPAddress(0) <> "0.0.0.0" Then
IsAvailable = True
str = IPAddress(0)
End If
End If
Next manObject
Catch exc As Exception
'Call ExceptionHandler(c_frmIdentity, exc)
'Return IsAvailable
End Try
Return IsAvailable
End Function 'IsNetworkAvailable
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.