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 "NOT Connected to the Internet!", vbInformation
Else
MsgBox "Connected to the Internet!", vbInformation
End If
End Sub

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


Comments

  • [b][red]This message was edited by Malcolm at 2002-10-21 1:35:41[/red][/b][hr]
    : 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 "NOT Connected to the Internet!", vbInformation
    : Else
    : MsgBox "Connected to the Internet!", vbInformation
    : End If
    : End Sub
    :
    : *********************************************
    : *********************************************
    :
    :
    :

    It is working on my computer.

    I tested it while I was on line and it said it was connected, and then tested after I went offline using the File Menu of Internet Explorer and it said it wasn't connected. I haven't tested when my phone lines not connected as I don't want to make another phone call. I'll try it when I disconnect and get back to you tomorrow if it doesn't work, otherwise assume it worked. I think it would be pretty safe to assume that it's going to work when I'm totally connected anyway.







  • [grey]Internet connection: Network to linuxbox and out on aDSL.

    DjSpirit, I {am|am not} connected.[/grey]
  • ummm i was thinking, if yahoo.com happens to be blocked from internet access for whatever reason (i.e. net nanny) then it might not work. i dont have a prog like that so if u have 1 block it and check it. just a thought.
    [b][green]Koozime![/green][/b]

  • : ummm i was thinking, if yahoo.com happens to be blocked from internet access for whatever reason (i.e. net nanny) then it might not work. i dont have a prog like that so if u have 1 block it and check it. just a thought.
    : [b][green]Koozime![/green][/b]
    :
    :

    Maybe the way around that would be to check more than one site (Maybe 4 to 5). If all of the fail then its off line, then if one of them are OK then its online.

    Although theres been occasions were my computers made a bad connection to the internet and won't load anything. So it would probably say its offline in this case too.



Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories