Detecting Internet Connection

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Adam Parkin

    Detecting Internet Connection

    Hello all, I need to be able to detect if there is an active available
    Internet connection in my VB6 program. In my program I'm using the Internet
    Transfer Control to transfer some files by HTTP, but as it stands now,
    there's no code to detect if there is in fact a network connection available
    before I try sending.

    Is there some easy way to do this?

    Thanks,

    Adam


  • mayayana

    #2
    Re: Detecting Internet Connection

    Private Declare Function InternetGetConn ectedState Lib "wininet.dl l" (ByRef
    dwflags As Long, ByVal dwReserved As Long) As Long

    Public Function IsOnline() As Boolean
    Dim LFlags As Long
    IsOnline = InternetGetConn ectedState(LFla gs, 0&)
    End Function

    --
    --
    Adam Parkin <skdfja@dfaslk. com> wrote in message
    news:qm8mc.2530 4$U75.24635@edt nps89...[color=blue]
    > Hello all, I need to be able to detect if there is an active available
    > Internet connection in my VB6 program. In my program I'm using the[/color]
    Internet[color=blue]
    > Transfer Control to transfer some files by HTTP, but as it stands now,
    > there's no code to detect if there is in fact a network connection[/color]
    available[color=blue]
    > before I try sending.
    >
    > Is there some easy way to do this?
    >
    > Thanks,
    >
    > Adam
    >
    >[/color]


    Comment

    • Adam Parkin

      #3
      Re: Detecting Internet Connection

      Thanks, that works perfectly....

      Adam

      "mayayana" <mayaXXyaYYna1a @mindZZspring.c om> wrote in message
      news:yZemc.6463 $a47.4420@newsr ead3.news.atl.e arthlink.net...[color=blue]
      > Private Declare Function InternetGetConn ectedState Lib "wininet.dl l"[/color]
      (ByRef[color=blue]
      > dwflags As Long, ByVal dwReserved As Long) As Long
      >
      > Public Function IsOnline() As Boolean
      > Dim LFlags As Long
      > IsOnline = InternetGetConn ectedState(LFla gs, 0&)
      > End Function
      >
      > --
      > --
      > Adam Parkin <skdfja@dfaslk. com> wrote in message
      > news:qm8mc.2530 4$U75.24635@edt nps89...[color=green]
      > > Hello all, I need to be able to detect if there is an active available
      > > Internet connection in my VB6 program. In my program I'm using the[/color]
      > Internet[color=green]
      > > Transfer Control to transfer some files by HTTP, but as it stands now,
      > > there's no code to detect if there is in fact a network connection[/color]
      > available[color=green]
      > > before I try sending.
      > >
      > > Is there some easy way to do this?
      > >
      > > Thanks,
      > >
      > > Adam
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • S.W. Rasmussen

        #4
        Re: Detecting Internet Connection

        not always in my experience: on winXP connected to the IN by modem,
        InternetGetConn ectedState returns True also when the modem is disconnected.
        InternetCheckCo nnection on the other hand returns the correct connection
        state (with lpszUrl = http://www.google.com for example) but is much slower
        as an connection attempt is involved. On win2K InternetGetConn ectedState
        always returns the correct connected state.

        Cheers
        Soeren

        "Adam Parkin" <skdfja@dfaslk. com> wrote in message
        news:NYimc.2614 4$U75.4774@edtn ps89...[color=blue]
        > Thanks, that works perfectly....
        >
        > Adam
        >
        > "mayayana" <mayaXXyaYYna1a @mindZZspring.c om> wrote in message
        > news:yZemc.6463 $a47.4420@newsr ead3.news.atl.e arthlink.net...[color=green]
        > > Private Declare Function InternetGetConn ectedState Lib "wininet.dl l"[/color]
        > (ByRef[color=green]
        > > dwflags As Long, ByVal dwReserved As Long) As Long
        > >
        > > Public Function IsOnline() As Boolean
        > > Dim LFlags As Long
        > > IsOnline = InternetGetConn ectedState(LFla gs, 0&)
        > > End Function
        > >
        > > --
        > > --
        > > Adam Parkin <skdfja@dfaslk. com> wrote in message
        > > news:qm8mc.2530 4$U75.24635@edt nps89...[color=darkred]
        > > > Hello all, I need to be able to detect if there is an active available
        > > > Internet connection in my VB6 program. In my program I'm using the[/color]
        > > Internet[color=darkred]
        > > > Transfer Control to transfer some files by HTTP, but as it stands now,
        > > > there's no code to detect if there is in fact a network connection[/color]
        > > available[color=darkred]
        > > > before I try sending.
        > > >
        > > > Is there some easy way to do this?
        > > >
        > > > Thanks,
        > > >
        > > > Adam
        > > >
        > > >[/color]
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • S.W. Rasmussen

          #5
          Re: Detecting Internet Connection

          addendum: see http://www.freevbcode.com/ShowCode.Asp?ID=632 for details.

          Soeren

          "S.W. Rasmussen" <swr@seqtools.d k> wrote in message
          news:409c7eb7$0 $436$edfadb0f@d read14.news.tel e.dk...[color=blue]
          > not always in my experience: on winXP connected to the IN by modem,
          > InternetGetConn ectedState returns True also when the modem is[/color]
          disconnected.[color=blue]
          > InternetCheckCo nnection on the other hand returns the correct connection
          > state (with lpszUrl = http://www.google.com for example) but is much[/color]
          slower[color=blue]
          > as an connection attempt is involved. On win2K InternetGetConn ectedState
          > always returns the correct connected state.
          >
          > Cheers
          > Soeren
          >
          > "Adam Parkin" <skdfja@dfaslk. com> wrote in message
          > news:NYimc.2614 4$U75.4774@edtn ps89...[color=green]
          > > Thanks, that works perfectly....
          > >
          > > Adam
          > >
          > > "mayayana" <mayaXXyaYYna1a @mindZZspring.c om> wrote in message
          > > news:yZemc.6463 $a47.4420@newsr ead3.news.atl.e arthlink.net...[color=darkred]
          > > > Private Declare Function InternetGetConn ectedState Lib "wininet.dl l"[/color]
          > > (ByRef[color=darkred]
          > > > dwflags As Long, ByVal dwReserved As Long) As Long
          > > >
          > > > Public Function IsOnline() As Boolean
          > > > Dim LFlags As Long
          > > > IsOnline = InternetGetConn ectedState(LFla gs, 0&)
          > > > End Function
          > > >
          > > > --
          > > > --
          > > > Adam Parkin <skdfja@dfaslk. com> wrote in message
          > > > news:qm8mc.2530 4$U75.24635@edt nps89...
          > > > > Hello all, I need to be able to detect if there is an active[/color][/color][/color]
          available[color=blue][color=green][color=darkred]
          > > > > Internet connection in my VB6 program. In my program I'm using the
          > > > Internet
          > > > > Transfer Control to transfer some files by HTTP, but as it stands[/color][/color][/color]
          now,[color=blue][color=green][color=darkred]
          > > > > there's no code to detect if there is in fact a network connection
          > > > available
          > > > > before I try sending.
          > > > >
          > > > > Is there some easy way to do this?
          > > > >
          > > > > Thanks,
          > > > >
          > > > > Adam
          > > > >
          > > > >
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          • mayayana

            #6
            Re: Detecting Internet Connection



            --[color=blue]
            > not always in my experience: on winXP connected to the IN by modem,
            > InternetGetConn ectedState returns True also when the modem is[/color]
            disconnected.[color=blue]
            > InternetCheckCo nnection on the other hand returns the correct connection
            > state (with lpszUrl = http://www.google.com for example) but is much[/color]
            slower[color=blue]
            > as an connection attempt is involved. On win2K InternetGetConn ectedState
            > always returns the correct connected state.
            >[/color]

            That's good to know. If that's a consistent bug in XP then I guess
            it would require using InternetGetConn ectedState and a Registry read
            in conjunction in order to be sure.


            Comment

            • J French

              #7
              Re: Detecting Internet Connection

              On Sat, 08 May 2004 13:30:03 GMT, "mayayana"
              <mayaXXyaYYna1a @mindZZspring.c om> wrote:
              [color=blue]
              >
              >
              >--[color=green]
              >> not always in my experience: on winXP connected to the IN by modem,
              >> InternetGetConn ectedState returns True also when the modem is[/color]
              >disconnected .[color=green]
              >> InternetCheckCo nnection on the other hand returns the correct connection
              >> state (with lpszUrl = http://www.google.com for example) but is much[/color]
              >slower[color=green]
              >> as an connection attempt is involved. On win2K InternetGetConn ectedState
              >> always returns the correct connected state.
              >>[/color]
              >
              > That's good to know. If that's a consistent bug in XP then I guess
              >it would require using InternetGetConn ectedState and a Registry read
              >in conjunction in order to be sure.[/color]

              I'm no expert on this, but from what I've picked up, the only real
              test is to make a connection.

              Comment

              • S.W. Rasmussen

                #8
                Re: Detecting Internet Connection

                yes, according to the link previously posted this is correct although it
                appears a bit unprofessional as it introduces a delay outside vb control
                while pinging the probe url.

                "J French" <erewhon@nowher e.com> wrote in message
                news:409cf952.3 5940089@news.bt click.com...[color=blue]
                > On Sat, 08 May 2004 13:30:03 GMT, "mayayana"
                > <mayaXXyaYYna1a @mindZZspring.c om> wrote:
                >[color=green]
                > >
                > >
                > >--[color=darkred]
                > >> not always in my experience: on winXP connected to the IN by modem,
                > >> InternetGetConn ectedState returns True also when the modem is[/color]
                > >disconnected .[color=darkred]
                > >> InternetCheckCo nnection on the other hand returns the correct[/color][/color][/color]
                connection[color=blue][color=green][color=darkred]
                > >> state (with lpszUrl = http://www.google.com for example) but is much[/color]
                > >slower[color=darkred]
                > >> as an connection attempt is involved. On win2K[/color][/color][/color]
                InternetGetConn ectedState[color=blue][color=green][color=darkred]
                > >> always returns the correct connected state.
                > >>[/color]
                > >
                > > That's good to know. If that's a consistent bug in XP then I guess
                > >it would require using InternetGetConn ectedState and a Registry read
                > >in conjunction in order to be sure.[/color]
                >
                > I'm no expert on this, but from what I've picked up, the only real
                > test is to make a connection.[/color]


                Comment

                • mayayana

                  #9
                  Re: Detecting Internet Connection

                  I guess you're right. If the API returns True and the
                  Registry setting for the modem returns False there's
                  still uncertainty over whether it's a disconnected
                  modem or an active connection of another type.
                  I'm amazed that such a major bug hasn't been fixed.
                  [color=blue]
                  > yes, according to the link previously posted this is correct although it
                  > appears a bit unprofessional as it introduces a delay outside vb control
                  > while pinging the probe url.
                  >
                  > "J French" <erewhon@nowher e.com> wrote in message
                  > news:409cf952.3 5940089@news.bt click.com...[color=green]
                  > > On Sat, 08 May 2004 13:30:03 GMT, "mayayana"
                  > > <mayaXXyaYYna1a @mindZZspring.c om> wrote:
                  > >[color=darkred]
                  > > >
                  > > >
                  > > >--
                  > > >> not always in my experience: on winXP connected to the IN by modem,
                  > > >> InternetGetConn ectedState returns True also when the modem is
                  > > >disconnected .
                  > > >> InternetCheckCo nnection on the other hand returns the correct[/color][/color]
                  > connection[color=green][color=darkred]
                  > > >> state (with lpszUrl = http://www.google.com for example) but is much
                  > > >slower
                  > > >> as an connection attempt is involved. On win2K[/color][/color]
                  > InternetGetConn ectedState[color=green][color=darkred]
                  > > >> always returns the correct connected state.
                  > > >>
                  > > >
                  > > > That's good to know. If that's a consistent bug in XP then I guess
                  > > >it would require using InternetGetConn ectedState and a Registry read
                  > > >in conjunction in order to be sure.[/color]
                  > >
                  > > I'm no expert on this, but from what I've picked up, the only real
                  > > test is to make a connection.[/color]
                  >
                  >[/color]


                  Comment

                  • S.W. Rasmussen

                    #10
                    Re: Detecting Internet Connection

                    Having identified the internet connection status bug in XP the next question
                    then is: how to get information on the current OS system (to differentiate
                    the IN connection status check). With API GetVersion() I get major version =
                    5 and minor = 2 for both win2000 and XP. Is there a way of finding out
                    whether the user runs XP or 2000?

                    Soeren

                    "mayayana" <mayaXXyaYYna1a @mindZZspring.c om> wrote in message
                    news:a_enc.9787 $8S1.4913@newsr ead2.news.atl.e arthlink.net...[color=blue]
                    > I guess you're right. If the API returns True and the
                    > Registry setting for the modem returns False there's
                    > still uncertainty over whether it's a disconnected
                    > modem or an active connection of another type.
                    > I'm amazed that such a major bug hasn't been fixed.
                    >[color=green]
                    > > yes, according to the link previously posted this is correct although it
                    > > appears a bit unprofessional as it introduces a delay outside vb control
                    > > while pinging the probe url.
                    > >
                    > > "J French" <erewhon@nowher e.com> wrote in message
                    > > news:409cf952.3 5940089@news.bt click.com...[color=darkred]
                    > > > On Sat, 08 May 2004 13:30:03 GMT, "mayayana"
                    > > > <mayaXXyaYYna1a @mindZZspring.c om> wrote:
                    > > >
                    > > > >
                    > > > >
                    > > > >--
                    > > > >> not always in my experience: on winXP connected to the IN by modem,
                    > > > >> InternetGetConn ectedState returns True also when the modem is
                    > > > >disconnected .
                    > > > >> InternetCheckCo nnection on the other hand returns the correct[/color]
                    > > connection[color=darkred]
                    > > > >> state (with lpszUrl = http://www.google.com for example) but is[/color][/color][/color]
                    much[color=blue][color=green][color=darkred]
                    > > > >slower
                    > > > >> as an connection attempt is involved. On win2K[/color]
                    > > InternetGetConn ectedState[color=darkred]
                    > > > >> always returns the correct connected state.
                    > > > >>
                    > > > >
                    > > > > That's good to know. If that's a consistent bug in XP then I[/color][/color][/color]
                    guess[color=blue][color=green][color=darkred]
                    > > > >it would require using InternetGetConn ectedState and a Registry read
                    > > > >in conjunction in order to be sure.
                    > > >
                    > > > I'm no expert on this, but from what I've picked up, the only real
                    > > > test is to make a connection.[/color]
                    > >
                    > >[/color]
                    >
                    >[/color]


                    Comment

                    • mayayana

                      #11
                      Re: Detecting Internet Connection

                      You can use GetVersionEx.

                      Public Type OSVERSIONINFO
                      dwOSVersionInfo Size As Long
                      dwMajorVersion As Long
                      dwMinorVersion As Long
                      dwBuildNumber As Long
                      dwPlatformId As Long
                      szCSDVersion As String * 128
                      End Type

                      Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersion ExA"
                      (lpVersionInfor mation As OSVERSIONINFO) As Long

                      dwPlatformId returns 1 for 9x and 2 for NT
                      dwMajorVersion returns 5 for 2000/XP
                      dwMinorVersion returns 0 for 2000, 1 for XP.
                      I've also seen a v. 5.2 in my weblogs, which I guess
                      may be the version of 2003 server.


                      [color=blue]
                      > Having identified the internet connection status bug in XP the next[/color]
                      question[color=blue]
                      > then is: how to get information on the current OS system (to differentiate
                      > the IN connection status check). With API GetVersion() I get major version[/color]
                      =[color=blue]
                      > 5 and minor = 2 for both win2000 and XP. Is there a way of finding out
                      > whether the user runs XP or 2000?
                      >
                      > Soeren
                      >
                      > "mayayana" <mayaXXyaYYna1a @mindZZspring.c om> wrote in message
                      > news:a_enc.9787 $8S1.4913@newsr ead2.news.atl.e arthlink.net...[color=green]
                      > > I guess you're right. If the API returns True and the
                      > > Registry setting for the modem returns False there's
                      > > still uncertainty over whether it's a disconnected
                      > > modem or an active connection of another type.
                      > > I'm amazed that such a major bug hasn't been fixed.
                      > >[color=darkred]
                      > > > yes, according to the link previously posted this is correct although[/color][/color][/color]
                      it[color=blue][color=green][color=darkred]
                      > > > appears a bit unprofessional as it introduces a delay outside vb[/color][/color][/color]
                      control[color=blue][color=green][color=darkred]
                      > > > while pinging the probe url.
                      > > >
                      > > > "J French" <erewhon@nowher e.com> wrote in message
                      > > > news:409cf952.3 5940089@news.bt click.com...
                      > > > > On Sat, 08 May 2004 13:30:03 GMT, "mayayana"
                      > > > > <mayaXXyaYYna1a @mindZZspring.c om> wrote:
                      > > > >
                      > > > > >
                      > > > > >
                      > > > > >--
                      > > > > >> not always in my experience: on winXP connected to the IN by[/color][/color][/color]
                      modem,[color=blue][color=green][color=darkred]
                      > > > > >> InternetGetConn ectedState returns True also when the modem is
                      > > > > >disconnected .
                      > > > > >> InternetCheckCo nnection on the other hand returns the correct
                      > > > connection
                      > > > > >> state (with lpszUrl = http://www.google.com for example) but is[/color][/color]
                      > much[color=green][color=darkred]
                      > > > > >slower
                      > > > > >> as an connection attempt is involved. On win2K
                      > > > InternetGetConn ectedState
                      > > > > >> always returns the correct connected state.
                      > > > > >>
                      > > > > >
                      > > > > > That's good to know. If that's a consistent bug in XP then I[/color][/color]
                      > guess[color=green][color=darkred]
                      > > > > >it would require using InternetGetConn ectedState and a Registry[/color][/color][/color]
                      read[color=blue][color=green][color=darkred]
                      > > > > >in conjunction in order to be sure.
                      > > > >
                      > > > > I'm no expert on this, but from what I've picked up, the only real
                      > > > > test is to make a connection.
                      > > >
                      > > >[/color]
                      > >
                      > >[/color]
                      >
                      >[/color]


                      Comment

                      • S.W. Rasmussen

                        #12
                        Re: Detecting Internet Connection

                        thanks...

                        Soeren

                        "mayayana" <mayaXXyaYYna1a @mindZZspring.c om> wrote in message
                        news:yisnc.141$ zO3.96@newsread 2.news.atl.eart hlink.net...[color=blue]
                        > You can use GetVersionEx.
                        >
                        > Public Type OSVERSIONINFO
                        > dwOSVersionInfo Size As Long
                        > dwMajorVersion As Long
                        > dwMinorVersion As Long
                        > dwBuildNumber As Long
                        > dwPlatformId As Long
                        > szCSDVersion As String * 128
                        > End Type
                        >
                        > Public Declare Function GetVersionEx Lib "kernel32" Alias "GetVersion ExA"
                        > (lpVersionInfor mation As OSVERSIONINFO) As Long
                        >
                        > dwPlatformId returns 1 for 9x and 2 for NT
                        > dwMajorVersion returns 5 for 2000/XP
                        > dwMinorVersion returns 0 for 2000, 1 for XP.
                        > I've also seen a v. 5.2 in my weblogs, which I guess
                        > may be the version of 2003 server.
                        >
                        >
                        >[color=green]
                        > > Having identified the internet connection status bug in XP the next[/color]
                        > question[color=green]
                        > > then is: how to get information on the current OS system (to[/color][/color]
                        differentiate[color=blue][color=green]
                        > > the IN connection status check). With API GetVersion() I get major[/color][/color]
                        version[color=blue]
                        > =[color=green]
                        > > 5 and minor = 2 for both win2000 and XP. Is there a way of finding out
                        > > whether the user runs XP or 2000?
                        > >
                        > > Soeren
                        > >
                        > > "mayayana" <mayaXXyaYYna1a @mindZZspring.c om> wrote in message
                        > > news:a_enc.9787 $8S1.4913@newsr ead2.news.atl.e arthlink.net...[color=darkred]
                        > > > I guess you're right. If the API returns True and the
                        > > > Registry setting for the modem returns False there's
                        > > > still uncertainty over whether it's a disconnected
                        > > > modem or an active connection of another type.
                        > > > I'm amazed that such a major bug hasn't been fixed.
                        > > >
                        > > > > yes, according to the link previously posted this is correct[/color][/color][/color]
                        although[color=blue]
                        > it[color=green][color=darkred]
                        > > > > appears a bit unprofessional as it introduces a delay outside vb[/color][/color]
                        > control[color=green][color=darkred]
                        > > > > while pinging the probe url.
                        > > > >
                        > > > > "J French" <erewhon@nowher e.com> wrote in message
                        > > > > news:409cf952.3 5940089@news.bt click.com...
                        > > > > > On Sat, 08 May 2004 13:30:03 GMT, "mayayana"
                        > > > > > <mayaXXyaYYna1a @mindZZspring.c om> wrote:
                        > > > > >
                        > > > > > >
                        > > > > > >
                        > > > > > >--
                        > > > > > >> not always in my experience: on winXP connected to the IN by[/color][/color]
                        > modem,[color=green][color=darkred]
                        > > > > > >> InternetGetConn ectedState returns True also when the modem is
                        > > > > > >disconnected .
                        > > > > > >> InternetCheckCo nnection on the other hand returns the correct
                        > > > > connection
                        > > > > > >> state (with lpszUrl = http://www.google.com for example) but is[/color]
                        > > much[color=darkred]
                        > > > > > >slower
                        > > > > > >> as an connection attempt is involved. On win2K
                        > > > > InternetGetConn ectedState
                        > > > > > >> always returns the correct connected state.
                        > > > > > >>
                        > > > > > >
                        > > > > > > That's good to know. If that's a consistent bug in XP then I[/color]
                        > > guess[color=darkred]
                        > > > > > >it would require using InternetGetConn ectedState and a Registry[/color][/color]
                        > read[color=green][color=darkred]
                        > > > > > >in conjunction in order to be sure.
                        > > > > >
                        > > > > > I'm no expert on this, but from what I've picked up, the only real
                        > > > > > test is to make a connection.
                        > > > >
                        > > > >
                        > > >
                        > > >[/color]
                        > >
                        > >[/color]
                        >
                        >[/color]


                        Comment

                        Working...