|
-
Oct 20th, 2002, 06:02 PM
#1
Thread Starter
Addicted Member
Will you guys test this? (Internet Connection)
Hey everyone,
I found the following piece of code somewhere, and was just
wondering if you guys (and girls) would check it out to see if
it works OK for you.
I need a good, reliable code to check to see if the computer is
connected to the Internet. It needs to work with cable modems,
dial-up modems, and networks.
I'm pretty sure this will work fine, but I sure would appreciate it
if you would check it out.
Thanks in advance,
Ron
*********************************************
*********************************************
Private Const FLAG_ICC_FORCE_CONNECTION = &H1
Private Declare Function InternetCheckConnection Lib "wininet.dll" Alias "InternetCheckConnectionA" (ByVal lpszUrl As String, ByVal dwFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
If InternetCheckConnection("http://www.yahoo.com", FLAG_ICC_FORCE_CONNECTION, 0&) = 0 Then
MsgBox "Connection failed!", vbInformation
Else
MsgBox "Connection succeeded!", vbInformation
End If
End Sub
*********************************************
*********************************************
-
Oct 20th, 2002, 06:09 PM
#2
Frenzied Member
It cause my VB to crash and I cant even end task on it because it keeps replicating the project... so in terms of reliability.. in a word NO
Mega.
"If at first you don't succeed, then skydiving is not for you"
-
Oct 20th, 2002, 06:21 PM
#3
Lively Member
yeah worled fine
yeah. Worked fine for me. Tried it a few times. Very reliable
-
Oct 20th, 2002, 06:32 PM
#4
Fanatic Member
said connection succeeded whatever the hell that means
-
Oct 20th, 2002, 06:53 PM
#5
Thread Starter
Addicted Member
Hey Mega_Man ........do you know why it caused VB to crash?
-
Oct 21st, 2002, 04:01 AM
#6
Frenzied Member
Originally posted by rdcody
Hey Mega_Man ........do you know why it caused VB to crash?
Yes I do now... It wasn't your code, it was my firewall. Sorry.
However, I have tried your code on my machine at work which acceses the internet through a proxy and your code said "Connection Failed". I Don't know whether you can incorporate code to check for the existence of a proxy or not.
Anyway, hope this is usefull feedback.
Mega.
"If at first you don't succeed, then skydiving is not for you"
-
Oct 21st, 2002, 04:55 AM
#7
PowerPoster
This method is not foolproof. Often it might give you wrong values while working behind a proxy or firewalls. A better way is to ping(if a direct connection is possible) or to open a small page on the web through Inet control.
-
Oct 21st, 2002, 07:55 AM
#8
I wonder how many charact
Works with DSL connection on Xp with the XP firewall enabled with connection sharing...
-
Oct 21st, 2002, 08:02 AM
#9
Frenzied Member
Works for me , windows XP pro , behind router network. adsl connection
-
Oct 21st, 2002, 08:20 AM
#10
PowerPoster
The firewall built in the XP allows all traffic to pass. It blocks only the incoming traffic. A router is meant for routing traffic, and therefore it will succeed. This code is most likely to fail where proxy's and firewalls located on the network are used to access internet.
-
Oct 21st, 2002, 10:25 PM
#11
New Member
This is an almost direct example out of the API Guide 3.7. It works fine, but I don't know about the firewall thing.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|