473,382 Members | 1,329 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

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
Jul 17 '05 #1
11 20726
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef
dwflags As Long, ByVal dwReserved As Long) As Long

Public Function IsOnline() As Boolean
Dim LFlags As Long
IsOnline = InternetGetConnectedState(LFlags, 0&)
End Function

--
--
Adam Parkin <sk****@dfaslk.com> wrote in message
news:qm8mc.25304$U75.24635@edtnps89...
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

Jul 17 '05 #2
Thanks, that works perfectly....

Adam

"mayayana" <ma************@mindZZspring.com> wrote in message
news:yZ*****************@newsread3.news.atl.earthl ink.net...
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef dwflags As Long, ByVal dwReserved As Long) As Long

Public Function IsOnline() As Boolean
Dim LFlags As Long
IsOnline = InternetGetConnectedState(LFlags, 0&)
End Function

--
--
Adam Parkin <sk****@dfaslk.com> wrote in message
news:qm8mc.25304$U75.24635@edtnps89...
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


Jul 17 '05 #3
not always in my experience: on winXP connected to the IN by modem,
InternetGetConnectedState returns True also when the modem is disconnected.
InternetCheckConnection 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 InternetGetConnectedState
always returns the correct connected state.

Cheers
Soeren

"Adam Parkin" <sk****@dfaslk.com> wrote in message
news:NYimc.26144$U75.4774@edtnps89...
Thanks, that works perfectly....

Adam

"mayayana" <ma************@mindZZspring.com> wrote in message
news:yZ*****************@newsread3.news.atl.earthl ink.net...
Private Declare Function InternetGetConnectedState Lib "wininet.dll"

(ByRef
dwflags As Long, ByVal dwReserved As Long) As Long

Public Function IsOnline() As Boolean
Dim LFlags As Long
IsOnline = InternetGetConnectedState(LFlags, 0&)
End Function

--
--
Adam Parkin <sk****@dfaslk.com> wrote in message
news:qm8mc.25304$U75.24635@edtnps89...
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



Jul 17 '05 #4
addendum: see http://www.freevbcode.com/ShowCode.Asp?ID=632 for details.

Soeren

"S.W. Rasmussen" <sw*@seqtools.dk> wrote in message
news:40*********************@dread14.news.tele.dk. ..
not always in my experience: on winXP connected to the IN by modem,
InternetGetConnectedState returns True also when the modem is disconnected. InternetCheckConnection 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 InternetGetConnectedState
always returns the correct connected state.

Cheers
Soeren

"Adam Parkin" <sk****@dfaslk.com> wrote in message
news:NYimc.26144$U75.4774@edtnps89...
Thanks, that works perfectly....

Adam

"mayayana" <ma************@mindZZspring.com> wrote in message
news:yZ*****************@newsread3.news.atl.earthl ink.net...
Private Declare Function InternetGetConnectedState Lib "wininet.dll"

(ByRef
dwflags As Long, ByVal dwReserved As Long) As Long

Public Function IsOnline() As Boolean
Dim LFlags As Long
IsOnline = InternetGetConnectedState(LFlags, 0&)
End Function

--
--
Adam Parkin <sk****@dfaslk.com> wrote in message
news:qm8mc.25304$U75.24635@edtnps89...
> 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
>
>



Jul 17 '05 #5


--
not always in my experience: on winXP connected to the IN by modem,
InternetGetConnectedState returns True also when the modem is disconnected. InternetCheckConnection 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 InternetGetConnectedState
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 InternetGetConnectedState and a Registry read
in conjunction in order to be sure.
Jul 17 '05 #6
On Sat, 08 May 2004 13:30:03 GMT, "mayayana"
<ma************@mindZZspring.com> wrote:


--
not always in my experience: on winXP connected to the IN by modem,
InternetGetConnectedState returns True also when the modem is

disconnected.
InternetCheckConnection 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 InternetGetConnectedState
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 InternetGetConnectedState 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.
Jul 17 '05 #7
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" <er*****@nowhere.com> wrote in message
news:40***************@news.btclick.com...
On Sat, 08 May 2004 13:30:03 GMT, "mayayana"
<ma************@mindZZspring.com> wrote:


--
not always in my experience: on winXP connected to the IN by modem,
InternetGetConnectedState returns True also when the modem is

disconnected.
InternetCheckConnection 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 InternetGetConnectedState 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 InternetGetConnectedState 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.

Jul 17 '05 #8
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 although it
appears a bit unprofessional as it introduces a delay outside vb control
while pinging the probe url.

"J French" <er*****@nowhere.com> wrote in message
news:40***************@news.btclick.com...
On Sat, 08 May 2004 13:30:03 GMT, "mayayana"
<ma************@mindZZspring.com> wrote:


--
> not always in my experience: on winXP connected to the IN by modem,
> InternetGetConnectedState returns True also when the modem is
disconnected.
> InternetCheckConnection 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 InternetGetConnectedState> 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 InternetGetConnectedState 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.


Jul 17 '05 #9
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" <ma************@mindZZspring.com> wrote in message
news:a_*****************@newsread2.news.atl.earthl ink.net...
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 although it
appears a bit unprofessional as it introduces a delay outside vb control
while pinging the probe url.

"J French" <er*****@nowhere.com> wrote in message
news:40***************@news.btclick.com...
On Sat, 08 May 2004 13:30:03 GMT, "mayayana"
<ma************@mindZZspring.com> wrote:

>
>
>--
>> not always in my experience: on winXP connected to the IN by modem,
>> InternetGetConnectedState returns True also when the modem is
>disconnected.
>> InternetCheckConnection 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

InternetGetConnectedState
>> 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 InternetGetConnectedState 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.



Jul 17 '05 #10
You can use GetVersionEx.

Public Type OSVERSIONINFO
dwOSVersionInfoSize 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 "GetVersionExA"
(lpVersionInformation 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.
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" <ma************@mindZZspring.com> wrote in message
news:a_*****************@newsread2.news.atl.earthl ink.net...
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 although it appears a bit unprofessional as it introduces a delay outside vb control while pinging the probe url.

"J French" <er*****@nowhere.com> wrote in message
news:40***************@news.btclick.com...
> On Sat, 08 May 2004 13:30:03 GMT, "mayayana"
> <ma************@mindZZspring.com> wrote:
>
> >
> >
> >--
> >> not always in my experience: on winXP connected to the IN by modem, > >> InternetGetConnectedState returns True also when the modem is
> >disconnected.
> >> InternetCheckConnection 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
InternetGetConnectedState
> >> 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 InternetGetConnectedState 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.



Jul 17 '05 #11
thanks...

Soeren

"mayayana" <ma************@mindZZspring.com> wrote in message
news:yi**************@newsread2.news.atl.earthlink .net...
You can use GetVersionEx.

Public Type OSVERSIONINFO
dwOSVersionInfoSize 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 "GetVersionExA"
(lpVersionInformation 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.
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" <ma************@mindZZspring.com> wrote in message
news:a_*****************@newsread2.news.atl.earthl ink.net...
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
although it > appears a bit unprofessional as it introduces a delay outside vb control > while pinging the probe url.
>
> "J French" <er*****@nowhere.com> wrote in message
> news:40***************@news.btclick.com...
> > On Sat, 08 May 2004 13:30:03 GMT, "mayayana"
> > <ma************@mindZZspring.com> wrote:
> >
> > >
> > >
> > >--
> > >> not always in my experience: on winXP connected to the IN by modem, > > >> InternetGetConnectedState returns True also when the modem is
> > >disconnected.
> > >> InternetCheckConnection 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
> InternetGetConnectedState
> > >> 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 InternetGetConnectedState 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.
>
>



Jul 17 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Matt Hawley | last post by:
I'm facing a problem where I need to verify that my windows forms application has access to the internet before it can do anything. Currently, the only way I can think of is by creating a...
3
by: Elizabeth Harmon | last post by:
How can i detect if a user is connected to a newtork or the internet using ..Net? are there any examples out there? Any Help or links Greatly Appreciated TIA Samantha
0
Ali Rizwan
by: Ali Rizwan | last post by:
Hi all, I m facing a big problem... How can i detect that either the internet connection id dialup or is on LAN or is their both connection exists...... and what is the connection speed. And is...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.