Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > Communications > Check for Internet Connection


Reply
 
Thread Tools Display Modes
  #1  
Old 01-26-2003, 06:56 AM
Lachy Lachy is offline
Centurion
 
Join Date: Dec 2002
Location: England
Posts: 126
Default Check for Internet Connection


How do I accurately check if a computer has a connection to the internet?
Reply With Quote
  #2  
Old 01-26-2003, 07:20 AM
dgdolins1 dgdolins1 is offline
Centurion
 
Join Date: Dec 2002
Posts: 124
Default

Code:
Private Declare Function InternetAttemptConnect _ Lib "wininet" (ByVal dwReserved As Long) As Long _______________________________________________ Private Sub Form_Load() If Not InternetConnectionExists Then MsgBox "Internet connection is not present.", vbCritical, "Error" End If End Sub ________________________________________________ Public Function InternetConnectionExists() As Boolean InternetConnectionExists = (InternetAttemptConnect(ByVal 0&) = 0) End Function
Reply With Quote
  #3  
Old 01-26-2003, 08:07 PM
Lachy Lachy is offline
Centurion
 
Join Date: Dec 2002
Location: England
Posts: 126
Default

Thanks a lot.
Reply With Quote
  #4  
Old 01-26-2003, 10:03 PM
Lachy Lachy is offline
Centurion
 
Join Date: Dec 2002
Location: England
Posts: 126
Default

Now that i've tested it, i've found a problem. I am using ADSL, which uses 2 LAN connections to operate. One of the connections is perminant, which the other one is only active when you're connected to the Internet.

If only ONE of these connections is active, the function will return TRUE. But I do not have a connection to the internet.
Reply With Quote
  #5  
Old 01-27-2003, 07:31 AM
Garmour's Avatar
Garmour Garmour is offline
Back for a little while..

Retired Leader
* Expert *
 
Join Date: Oct 2002
Location: Behind you.....Boo
Posts: 2,199
Default

Does your ADSL connection use DHCP (Dynamic addressing). If so then you could interrogate the second LAN connection to see if it has an ip address.

Dos commands like IPCONFIG /ALL do this, along with API calls like
GetNetworkParams or GetAdaptersInfo
__________________

....but then, what would I know ?
Reply With Quote
  #6  
Old 01-27-2003, 03:14 PM
alcaholjunkie's Avatar
alcaholjunkie alcaholjunkie is offline
Centurion
 
Join Date: Sep 2002
Location: UK
Posts: 143
Default

maybe if you could get the gateway address of the adsl/cable modem then you could probly ping it to see if it is conneted.
__________________
*you are a fool of the highest calibre*
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->