Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to detect an internet connection

Status
Not open for further replies.

LordDuzy

Programmer
Feb 12, 2004
22
PL
I need my program to detect an internet connection. I need it because i want to use the internet transfer control when the computer is connected.
 
Check the InternetGetConnectedState API function. It returns a non-zero value when online, and zero when offline.
___
[tt]
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (lpdwFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
If InternetGetConnectedState(ByVal 0, 0) Then
MsgBox "connected"
Else
MsgBox "not connected"
End If
End Sub[/tt]
 
Be aware that there are some limitations with this call. We held a reasonably in-depth investigation into it in this forum a couple of years ago, but I sadly can't find the relevant thread. Instead, I'll provide this URL which flags some of the limitations
 
StrongM, I'd be interested in that URL you mentioned, and learning about the limitations as well... thanks for pointing out that there are limitations.

[fish] No Dolphins were harmed in the posting of this message... Dolphin Friendly Tuna!

Ever feel like you're banging your head against a tree? I did, so I cut down the tree.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top