Hi, How can I check through my application if computer is connected with internet or not (at the moment) I need a message if net is connected.
Thanks a lot Furqan
Hi, How can I check through my application if computer is connected with internet or not (at the moment) I need a message if net is connected.
Thanks a lot Furqan
I would try that. It's from VB 6, but I think you can easily convert it.
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef
dwflags As Long, ByVal dwReserved As Long) As Long
Public Function IsOnline() As Boolean
Dim LFlags As Long
IsOnline = InternetGetConnectedState(LFlags, 0&)
End Function
http://bytes.com/topic/visual-basic/answers/14551-detecting-internet-connection
ping. Dim response As Boolean = False response = My.Computer.Network.ping(google.com)
True, you have access, false, you don't, or the world is ending because google is offline.
Internet connectivity should be handled similar to file availability.
With files, you should typically not use File.Exists() to first see if you can open a file because the results might change on you between when you perform the check and when you act on the results, let alone the difference between mere existence and read permissions. You have to handle the exceptions anyway, and so that's really a better place to concentrate your efforts.
The same is true for internet access. The best option is generally to just go and do it, and concentrate your development time on your exception handler.