Results 1 to 11 of 11

Thread: Will you guys test this? (Internet Connection)

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    154

    Question 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

    *********************************************
    *********************************************

  2. #2
    Frenzied Member Mega_Man's Avatar
    Join Date
    Mar 2001
    Location
    North of England, South-East of Iceland
    Posts
    1,067
    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"

  3. #3
    Lively Member brjames's Avatar
    Join Date
    Jan 2000
    Location
    Tenby, Wales, UK
    Posts
    121

    yeah worled fine

    yeah. Worked fine for me. Tried it a few times. Very reliable

  4. #4
    Fanatic Member duc's Avatar
    Join Date
    Oct 2002
    Location
    STEAM
    Posts
    702
    said connection succeeded whatever the hell that means

  5. #5

    Thread Starter
    Addicted Member
    Join Date
    Aug 2000
    Posts
    154
    Hey Mega_Man ........do you know why it caused VB to crash?

  6. #6
    Frenzied Member Mega_Man's Avatar
    Join Date
    Mar 2001
    Location
    North of England, South-East of Iceland
    Posts
    1,067
    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"

  7. #7
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    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.

  8. #8
    I wonder how many charact
    Join Date
    Feb 2001
    Location
    Savage, MN, USA
    Posts
    3,704
    Works with DSL connection on Xp with the XP firewall enabled with connection sharing...

  9. #9
    Frenzied Member Ultimasnake's Avatar
    Join Date
    Feb 2002
    Location
    Amsterdam, holland
    Posts
    1,172
    Works for me , windows XP pro , behind router network. adsl connection
    For my PC and MS Smartphone 2003 software visit
    http://www.ultimasoftware.nl

  10. #10
    PowerPoster
    Join Date
    Aug 2000
    Location
    India
    Posts
    2,288
    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.

  11. #11
    New Member
    Join Date
    Jan 1999
    Location
    Cleveland
    Posts
    9
    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
  •  



Click Here to Expand Forum to Full Width