Discussion:
(BUG) InternetGetConnectedState API returns false result
(too old to reply)
Asesh
2008-03-29 14:00:01 UTC
Permalink
On XP, after installing IE 7 or 8 Beta 1, InternetGetConnectedState API will
most often return false result. I thought this bug would have been fixed in
IE 8 beta 1 but it's still not been fixed. To verify this just create a
simple application that will test whether a client is connected to the
internet or not using InternetGetConnectedState; it will return false result
most of the time but not always, despite the fact that am connected to the
internet. I have noticed the same problem with windows error reporting built
into xp, seems like it also calls that API to detect internet connection
status and I have had not been able to send so many error reports via error
reporting because it would tell me that it requires internet connection
though an active internet connection was present.
Rafael R. [Live Butterfly]
2008-03-29 15:18:52 UTC
Permalink
Hello,

Have you tried using the InternetCheckConnection [1] function to
determine if this is an API issue or a local issue?

[1] http://msdn2.microsoft.com/en-us/library/aa384702(VS.85).aspx

- Rafael
Post by Asesh
On XP, after installing IE 7 or 8 Beta 1, InternetGetConnectedState API will
most often return false result. I thought this bug would have been fixed in
IE 8 beta 1 but it's still not been fixed. To verify this just create a
simple application that will test whether a client is connected to the
internet or not using InternetGetConnectedState; it will return false result
most of the time but not always, despite the fact that am connected to the
internet. I have noticed the same problem with windows error reporting built
into xp, seems like it also calls that API to detect internet connection
status and I have had not been able to send so many error reports via error
reporting because it would tell me that it requires internet connection
though an active internet connection was present.
Asesh
2008-03-29 15:55:00 UTC
Permalink
It's definitely an API issue. I remember, I had posted this bug when IE 7
beta forum was active and there were some guys saying the same thing too in
my post but unfortunately, Microsoft released IE 7 just a couple of days
later w/o reviewing that post and the forum was closed. I have noticed this
on my college computers too.
Post by Rafael R. [Live Butterfly]
Hello,
Have you tried using the InternetCheckConnection [1] function to
determine if this is an API issue or a local issue?
[1] http://msdn2.microsoft.com/en-us/library/aa384702(VS.85).aspx
- Rafael
Post by Asesh
On XP, after installing IE 7 or 8 Beta 1, InternetGetConnectedState API will
most often return false result. I thought this bug would have been fixed in
IE 8 beta 1 but it's still not been fixed. To verify this just create a
simple application that will test whether a client is connected to the
internet or not using InternetGetConnectedState; it will return false result
most of the time but not always, despite the fact that am connected to the
internet. I have noticed the same problem with windows error reporting built
into xp, seems like it also calls that API to detect internet connection
status and I have had not been able to send so many error reports via error
reporting because it would tell me that it requires internet connection
though an active internet connection was present.
Asesh
2008-03-29 16:22:01 UTC
Permalink
I am just concerned with internet connection status not a connection to the
host. When I had IE 6 installed (i.e., before upgrading to IE 7 then IE 8
beta 1) it always used to return TRUE when ever I was connected to the
internet and so used to WER on XP. I don't know whether this bug exists on
Vista or not since I don't have VC++ or masm32 installed on Vista. Thanks
Post by Asesh
It's definitely an API issue. I remember, I had posted this bug when IE 7
beta forum was active and there were some guys saying the same thing too in
my post but unfortunately, Microsoft released IE 7 just a couple of days
later w/o reviewing that post and the forum was closed. I have noticed this
on my college computers too.
Post by Rafael R. [Live Butterfly]
Hello,
Have you tried using the InternetCheckConnection [1] function to
determine if this is an API issue or a local issue?
[1] http://msdn2.microsoft.com/en-us/library/aa384702(VS.85).aspx
- Rafael
Post by Asesh
On XP, after installing IE 7 or 8 Beta 1, InternetGetConnectedState API will
most often return false result. I thought this bug would have been fixed in
IE 8 beta 1 but it's still not been fixed. To verify this just create a
simple application that will test whether a client is connected to the
internet or not using InternetGetConnectedState; it will return false result
most of the time but not always, despite the fact that am connected to the
internet. I have noticed the same problem with windows error reporting built
into xp, seems like it also calls that API to detect internet connection
status and I have had not been able to send so many error reports via error
reporting because it would tell me that it requires internet connection
though an active internet connection was present.
Rafael R. [Live Butterfly]
2008-03-29 16:53:44 UTC
Permalink
Can you provide me with a test case? I can test on both Windows XP and
Windows Vista platforms for you.

- Rafael
Post by Asesh
I am just concerned with internet connection status not a connection to the
host. When I had IE 6 installed (i.e., before upgrading to IE 7 then IE 8
beta 1) it always used to return TRUE when ever I was connected to the
internet and so used to WER on XP. I don't know whether this bug exists on
Vista or not since I don't have VC++ or masm32 installed on Vista. Thanks
Asesh
2008-03-29 17:06:01 UTC
Permalink
This post might be inappropriate. Click to display it.
Asesh
2008-03-29 17:35:00 UTC
Permalink
C++ code:

#include <iostream>
using namespace std;

#include <conio.h>

#include <windows.h>
#include <wininet.h>

#pragma comment(lib, "wininet")

void main()
{
DWORD dwConnFlags;
if(::InternetGetConnectedState(&dwConnFlags, 0))
cout<<"You are connected";
else
cout<<"*** You are not connected ***";
_getch();
}

Hope that works.
Post by Asesh
I just use MASM32 and graphics designing software on this computer like 3ds
max and photoshop and don't have VC++ installed here. Got VC++ (VS 2008 pro)
.686
.model flat, stdcall
option casemap:none
; Header files
include c:\masm32\include\windows.inc
include c:\masm32\include\masm32.inc
include c:\masm32\include\kernel32.inc
include c:\masm32\include\user32.inc
include c:\masm32\macros\macros.asm
include c:\masm32\include\wininet.inc
; Library files
includelib c:\masm32\lib\user32.lib
includelib c:\masm32\lib\kernel32.lib
includelib c:\masm32\lib\masm32.lib
includelib c:\masm32\lib\wininet.lib
WSA_FLAG_OVERLAPPED EQU 1h
STD_OUTPUT_HANDLE EQU -0Bh
.data
_SOCKET dd 0h
_HANDLE dd 0h
szWindowTitle db "Aseshsoft Sniper", 0h
shellcodes1 db 55h, 8Bh, 0ECh, 0C9h, 33h, 0C0h, 0C3h, 0h
portScanner proto :DWORD, :DWORD
scanPorts proto :DWORD
cleanup proto :DWORD
.code
push offset szWindowTitle
call SetConsoleTitle
call main
push 1Bh
call GetAsyncKeyState
cmp eax, 0h
jne exitMainLoop
push 64h
call Sleep
jmp mainMessageLoop
push 0h
call ExitProcess
main proc
local dwFlags:DWORD
push 0h
lea eax, dwFlags
push eax
call InternetGetConnectedState
cmp eax, 0h
je _exitinternet
print chr$("The internet connection was detected", 0Ah)
ret
print chr$("Error the internet connection was not detected", 0Ah)
ret
main endp
portScanner proc dwInitPortNumber:DWORD, dwMaxPortNumber:DWORD
ret
portScanner endp
cleanup proc _socket:DWORD
ret
cleanup endp
end start
Run the application and press 'ESC' to close the application. Try running
the application a couple of times and monitor the output. Thanks
Post by Rafael R. [Live Butterfly]
Can you provide me with a test case? I can test on both Windows XP and
Windows Vista platforms for you.
- Rafael
Post by Asesh
I am just concerned with internet connection status not a connection to the
host. When I had IE 6 installed (i.e., before upgrading to IE 7 then IE 8
beta 1) it always used to return TRUE when ever I was connected to the
internet and so used to WER on XP. I don't know whether this bug exists on
Vista or not since I don't have VC++ or masm32 installed on Vista. Thanks
Rafael R. [Live Butterfly]
2008-03-29 18:28:19 UTC
Permalink
I can't reproduce on neither Windows XP or Windows Vista. When the
function returns FALSE, what is the value of dwConnFlags? Also, what
does GetLastError() return? (disassembly of InternetGetConnectedState
revealed it calls SetLastError)

- Rafael
<snipped>
Run the application and press 'ESC' to close the application. Try running
the application a couple of times and monitor the output. Thanks
Rafael R. [Live Butterfly]
2008-03-29 18:51:45 UTC
Permalink
Just FYI - This function ultimately just asks SENS (System Event
Notification Service) if the network is alive and caches the result (for
approx. 15 seconds). *All subsequent calls to the API will return the
cached result*

For troubleshooting purposes, try calling IsNetworkAlive directly:

BOOL IsNetworkAlive( LPDWORD lpdwFlags );
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/syncmgr/syncmgr/isnetworkalive.asp

- Rafael
<snipped>
Asesh
2008-03-30 15:34:00 UTC
Permalink
Tested again on both IE 7 and 8 beta 1, 1st argument to
InternetGetConnectedState is set to 0x10 (conn. description) and GetLastError
will return 0 when that API returns FALSE. Please run it's release version
manually from that Release folder a couple of times. It happens in Debug
version too.
Post by Rafael R. [Live Butterfly]
Just FYI - This function ultimately just asks SENS (System Event
Notification Service) if the network is alive and caches the result (for
approx. 15 seconds). *All subsequent calls to the API will return the
cached result*
BOOL IsNetworkAlive( LPDWORD lpdwFlags );
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/syncmgr/syncmgr/isnetworkalive.asp
- Rafael
<snipped>
Asesh
2008-03-30 15:48:00 UTC
Permalink
Snap shot:
Loading Image...
Rafael R. [Live Butterfly]
2008-03-30 16:30:45 UTC
Permalink
I tried both debug and release versions multiple times on all platforms
using ASM, C++, and C#. I cannot reproduce.

0x10 is an odd result. The INTERNET_CONNECTION_MODEM_BUSY flag isn't
used (in the code I'm looking at), so I'm not sure how you got that value...

FYI - Although the debug executable will initialize your dwConnFlags to
0, your release executable will not. That said, this particular function
will initialize your out variable, so you're safe.

To rule out your compilation environment, try my executable:
http://www.withinwindows.com/hosted/InternetGetConnectedState.exe
(requires Visual C++ 2005 SP1 runtime)
Post by Asesh
Tested again on both IE 7 and 8 beta 1, 1st argument to
InternetGetConnectedState is set to 0x10 (conn. description) and GetLastError
will return 0 when that API returns FALSE. Please run it's release version
manually from that Release folder a couple of times. It happens in Debug
version too.
Asesh
2008-03-30 20:24:00 UTC
Permalink
That InternetGetConnectedState.exe often says that am not connected:
Loading Image...

And, there's one explorer bug which still exists in XP and Vista. Here's
how to replicate it:
1: Rename any exe file to and set it's extension to pif.
2: Now right click that pif file and click Properties.
3: Now switch to Program tab, you see see a dialog box, click OK
4: Now click the Advanced. Now explorer will crash

Seems like WER calls InternetGetConnectedState too, so here's a screen shot
while explorer crashed:

Loading Image...
Post by Rafael R. [Live Butterfly]
I tried both debug and release versions multiple times on all platforms
using ASM, C++, and C#. I cannot reproduce.
0x10 is an odd result. The INTERNET_CONNECTION_MODEM_BUSY flag isn't
used (in the code I'm looking at), so I'm not sure how you got that value...
FYI - Although the debug executable will initialize your dwConnFlags to
0, your release executable will not. That said, this particular function
will initialize your out variable, so you're safe.
http://www.withinwindows.com/hosted/InternetGetConnectedState.exe
(requires Visual C++ 2005 SP1 runtime)
Post by Asesh
Tested again on both IE 7 and 8 beta 1, 1st argument to
InternetGetConnectedState is set to 0x10 (conn. description) and GetLastError
will return 0 when that API returns FALSE. Please run it's release version
manually from that Release folder a couple of times. It happens in Debug
version too.
Asesh
2008-03-30 20:40:00 UTC
Permalink
I told one of my friend who also uses XP and but IE 7 to run that file a
couple of times and he always got "You are connected" message. He ran that
file more than 20 times and always got that same message. By the way I use
cable internet and that friend of mine uses WiFi. Am just wondering, what's
wrong? it never used to happen when I had IE 6 installed...
Post by Asesh
http://cid-414198b9c7617196.skydrive.live.com/self.aspx/Public/IGCS.JPG
And, there's one explorer bug which still exists in XP and Vista. Here's
1: Rename any exe file to and set it's extension to pif.
2: Now right click that pif file and click Properties.
3: Now switch to Program tab, you see see a dialog box, click OK
4: Now click the Advanced. Now explorer will crash
Seems like WER calls InternetGetConnectedState too, so here's a screen shot
http://cid-414198b9c7617196.skydrive.live.com/self.aspx/Public/FPifBug.JPG
Post by Rafael R. [Live Butterfly]
I tried both debug and release versions multiple times on all platforms
using ASM, C++, and C#. I cannot reproduce.
0x10 is an odd result. The INTERNET_CONNECTION_MODEM_BUSY flag isn't
used (in the code I'm looking at), so I'm not sure how you got that value...
FYI - Although the debug executable will initialize your dwConnFlags to
0, your release executable will not. That said, this particular function
will initialize your out variable, so you're safe.
http://www.withinwindows.com/hosted/InternetGetConnectedState.exe
(requires Visual C++ 2005 SP1 runtime)
Post by Asesh
Tested again on both IE 7 and 8 beta 1, 1st argument to
InternetGetConnectedState is set to 0x10 (conn. description) and GetLastError
will return 0 when that API returns FALSE. Please run it's release version
manually from that Release folder a couple of times. It happens in Debug
version too.
Rafael R. [Live Butterfly]
2008-03-30 23:01:11 UTC
Permalink
Are you using the latest drivers for your network adapter/chipset? Any
unusual errors in the event log? Do you have any dial-up/VPN connections
configured on your machine?

- Rafael
Post by Asesh
I told one of my friend who also uses XP and but IE 7 to run that file a
couple of times and he always got "You are connected" message. He ran that
file more than 20 times and always got that same message. By the way I use
cable internet and that friend of mine uses WiFi. Am just wondering, what's
wrong? it never used to happen when I had IE 6 installed...
Asesh
2008-03-31 01:58:00 UTC
Permalink
Yes am using the latest drivers for my network card. I saw this message in
the event log and there are many such warning messages: Your computer has
automatically configured the IP address for the Network Card with network
address 0000E84E2B87. The IP address being used is 169.254.49.233. Tye:
Warning Source: Dhcp. Anyway thanks
Post by Rafael R. [Live Butterfly]
Are you using the latest drivers for your network adapter/chipset? Any
unusual errors in the event log? Do you have any dial-up/VPN connections
configured on your machine?
- Rafael
Post by Asesh
I told one of my friend who also uses XP and but IE 7 to run that file a
couple of times and he always got "You are connected" message. He ran that
file more than 20 times and always got that same message. By the way I use
cable internet and that friend of mine uses WiFi. Am just wondering, what's
wrong? it never used to happen when I had IE 6 installed...
Robert Aldwinckle
2008-03-31 06:46:23 UTC
Permalink
Post by Asesh
I told one of my friend who also uses XP and but IE 7 to run that file a
couple of times and he always got "You are connected" message. He ran that
file more than 20 times and always got that same message.
By the way I use cable internet and that friend of mine uses WiFi.
That may not be sufficient description of your connection.
E.g. I have DSL on XPsp2. The clearest demonstration
that the problem is in the OS and not IE can be shown
using XP's Help and Support (e.g. press Win-F1) and
click on Get Support, or find information in Windows XP Newsgroups
then click on Get help from Microsoft. I then get:
<transcript>
Internet Connection is Required
To view this page, you must be connected to the Internet.
To connect to the Internet now, click Connect.

<link text="Tell me more about connecting to the Internet."/>
<button label="Connect"/>
</transcript>

When I click the Connect button I am given an opportunity
to hang up my DSL connection (or choose a dial-up connection)!

The only way I have ever been able to use that Get help... link
is to actually hang up and make sure that Help & Support gets
the first connection. YMMV.
Post by Asesh
Am just wondering, what's
wrong? it never used to happen when I had IE 6 installed...
A related problem happens with both OE and WLMail.
However, for them I can specify which connection I want
to use (e.g. instead of Any Connection, which soon degrades
to LAN Connection). I think that that is the problem--that
the LAN Connection has imperfect connectivity, whether
for DNS or something else I don't know and just quickly
causes problem symptoms like these.

Having either OE or WLMail refresh the Internet connection
with the real DSL connection seems to avoid most of my problem
symptoms in this regard, except the Help & Support one.


FWIW

Robert Aldwinckle
---
Asesh
2008-04-01 02:35:02 UTC
Permalink
Then have you tried running that InternetGetConnectedState.exe application
that Mr. Rafeal has posted? If possible run that sample a couple of times
when you are connected to the internet and let us know what it says. "You are
connected" means an active internet connection is present; and "You are not
connected" mean an active internet connection is not present. Here, it often
displays false result.
Post by Robert Aldwinckle
Post by Asesh
I told one of my friend who also uses XP and but IE 7 to run that file a
couple of times and he always got "You are connected" message. He ran that
file more than 20 times and always got that same message.
By the way I use cable internet and that friend of mine uses WiFi.
That may not be sufficient description of your connection.
E.g. I have DSL on XPsp2. The clearest demonstration
that the problem is in the OS and not IE can be shown
using XP's Help and Support (e.g. press Win-F1) and
click on Get Support, or find information in Windows XP Newsgroups
<transcript>
Internet Connection is Required
To view this page, you must be connected to the Internet.
To connect to the Internet now, click Connect.
<link text="Tell me more about connecting to the Internet."/>
<button label="Connect"/>
</transcript>
When I click the Connect button I am given an opportunity
to hang up my DSL connection (or choose a dial-up connection)!
The only way I have ever been able to use that Get help... link
is to actually hang up and make sure that Help & Support gets
the first connection. YMMV.
Post by Asesh
Am just wondering, what's
wrong? it never used to happen when I had IE 6 installed...
A related problem happens with both OE and WLMail.
However, for them I can specify which connection I want
to use (e.g. instead of Any Connection, which soon degrades
to LAN Connection). I think that that is the problem--that
the LAN Connection has imperfect connectivity, whether
for DNS or something else I don't know and just quickly
causes problem symptoms like these.
Having either OE or WLMail refresh the Internet connection
with the real DSL connection seems to avoid most of my problem
symptoms in this regard, except the Help & Support one.
FWIW
Robert Aldwinckle
---
Robert Aldwinckle
2008-04-01 19:20:16 UTC
Permalink
Post by Asesh
Then have you tried running that InternetGetConnectedState.exe application
that Mr. Rafeal has posted? If possible run that sample a couple of times
when you are connected to the internet and let us know what it says. "You are
connected" means an active internet connection is present; and
"You are not connected" mean an active internet
connection is not present.
Not necessarily. It apparently can be misled by setting
Work Offline. (GlobalUserOffline flag in the registry.)
Post by Asesh
Here, it often displays false result.
Do you use Work Offline much or notice it being set
sometimes unexpectedly?

BTW IE8 appears not to be as aware of independent
changes in GlobalUserOffline as older versions of IE.
E.g. I can no longer rely on the icon in the IE Status bar
for knowing the actual state of that value. This is particularly
inconvenient with WLMail since it has omitted support for
checking and toggling Work Offline in its composition windows
completely.

https://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=333230

Perhaps there is more to that symptom than appears
at first glance? ; )


Did you try the Help & Support test I mentioned?
Also, if you're not sure how to describe your connections
the output of ipconfig /all (from a cmd window)
could help clarify what you're using. ; )


Robert
---
Post by Asesh
Post by Robert Aldwinckle
Post by Asesh
I told one of my friend who also uses XP and but IE 7 to run that file a
couple of times and he always got "You are connected" message. He ran that
file more than 20 times and always got that same message.
By the way I use cable internet and that friend of mine uses WiFi.
That may not be sufficient description of your connection.
E.g. I have DSL on XPsp2. The clearest demonstration
that the problem is in the OS and not IE can be shown
using XP's Help and Support (e.g. press Win-F1) and
click on Get Support, or find information in Windows XP Newsgroups
...
Asesh
2008-04-02 16:04:00 UTC
Permalink
I don't use work offline option, it will always remain as is on my system.
But just wanted to know if you experience that samething that I do on this XP
system i.e., InternetGetConnectedState API returning false result, looking at
your older post...Anyway thanks
Post by Robert Aldwinckle
Post by Asesh
Then have you tried running that InternetGetConnectedState.exe application
that Mr. Rafeal has posted? If possible run that sample a couple of times
when you are connected to the internet and let us know what it says. "You are
connected" means an active internet connection is present; and
"You are not connected" mean an active internet
connection is not present.
Not necessarily. It apparently can be misled by setting
Work Offline. (GlobalUserOffline flag in the registry.)
Post by Asesh
Here, it often displays false result.
Do you use Work Offline much or notice it being set
sometimes unexpectedly?
BTW IE8 appears not to be as aware of independent
changes in GlobalUserOffline as older versions of IE.
E.g. I can no longer rely on the icon in the IE Status bar
for knowing the actual state of that value. This is particularly
inconvenient with WLMail since it has omitted support for
checking and toggling Work Offline in its composition windows
completely.
https://connect.microsoft.com/IE/feedback/ViewFeedback.aspx?FeedbackID=333230
Perhaps there is more to that symptom than appears
at first glance? ; )
Did you try the Help & Support test I mentioned?
Also, if you're not sure how to describe your connections
the output of ipconfig /all (from a cmd window)
could help clarify what you're using. ; )
Robert
---
Post by Asesh
Post by Robert Aldwinckle
Post by Asesh
I told one of my friend who also uses XP and but IE 7 to run that file a
couple of times and he always got "You are connected" message. He ran that
file more than 20 times and always got that same message.
By the way I use cable internet and that friend of mine uses WiFi.
That may not be sufficient description of your connection.
E.g. I have DSL on XPsp2. The clearest demonstration
that the problem is in the OS and not IE can be shown
using XP's Help and Support (e.g. press Win-F1) and
click on Get Support, or find information in Windows XP Newsgroups
....
Loading...