Results 1 to 4 of 4

Thread: InternetGetConnectedState Wrong. Why?

  1. #1

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    InternetGetConnectedState Wrong. Why?

    I am using this code and it tells me that I am online even when my Comcast modem is offline. Why?
    Code:
    Public Declare Function InternetGetConnectedState _
        Lib "wininet.dll" (ByRef lpdwFlags As Long, _
        ByVal dwReserved As Long) As Long
        'Local system uses a modem to connect to
        '     the Internet.
        Public Const INTERNET_CONNECTION_MODEM As Long = &H1
        'Local system uses a LAN to connect to t
        '     he Internet.
        Public Const INTERNET_CONNECTION_LAN As Long = &H2
        'Local system uses a proxy server to con
        '     nect to the Internet.
        Public Const INTERNET_CONNECTION_PROXY As Long = &H4
        'No longer used.
        Public Const INTERNET_CONNECTION_MODEM_BUSY As Long = &H8
        Public Const INTERNET_RAS_INSTALLED As Long = &H10
        Public Const INTERNET_CONNECTION_OFFLINE As Long = &H20
        Public Const INTERNET_CONNECTION_CONFIGURED As Long = &H40
    
    
    
    'InternetGetConnectedState wrapper functions
    Public Function IsNetConnectOnline() As Boolean
        On Error GoTo err
        'no flags needed here - the API returns
        '     True
        'if there is a connection of any type
        IsNetConnectOnline = InternetGetConnectedState(0&, 0&)
        Exit Function
    err:
        err.Raise vbObjectError + 773, , "IsNetConnectOnline"
    End Function

  2. #2
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: InternetGetConnectedState Wrong. Why?

    It might be better to PING a site that is usually up, and trap the code, to tell if it's online. Your API determines the state. It will let you know if an Internet connection has been set up, not if it's online.

  3. #3

    Thread Starter
    PowerPoster
    Join Date
    Jan 2001
    Location
    Florida
    Posts
    3,216

    Re: InternetGetConnectedState Wrong. Why?

    thanks I will do that

  4. #4
    I'm about to be a PowerPoster!
    Join Date
    Jan 2005
    Location
    Everywhere
    Posts
    13,647

    Re: InternetGetConnectedState Wrong. Why?

    if you use a router like a DSL modem then it will always say you are online for some reason.

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