Does anyone know of the existence of a windoze message that should be called something like WM_CONNECTEDTOINTERNET? Responding to such a message would be so much more convenient than having to poll GetInternetConnectedState() every second or so.
Posted on 2001-12-02 03:07:57 by peterverstappen

called something like WM_CONNECTEDTOINTERNET?

No, a message like that doesn't exist, and why should it? Windows can't tell the difference between the internet or an intranet, it treats them both as just a network.

having to poll GetInternetConnectedState() every second or so.

I don't know what that function is, it is obviously a custom library or something. Why don't you put that function into a timed loop in a separate thread, it can then signal your main thread when connectivity is achieved.
Posted on 2001-12-02 04:07:33 by sluggy
InternetGetConnectedState is actually a real API. It lives in wininet.dll. The data below I got from my copy of Api-Guide for VB, available from

Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long

? lpdwFlags
Pointer to an unsigned long integer variable where the connection description should be returned. This can be a combination of the following values:
Local system has a valid connection to the Internet, but it may or may not be currently connected.
Local system uses a local area network to connect to the Internet.
Local system uses a modem to connect to the Internet.
No longer used.
Local system is in offline mode.
Local system uses a proxy server to connect to the Internet.
Local system has RAS installed.

? dwReserved
Reserved. Must be set to zero.

Returns TRUE if there is an Internet connection, or FALSE otherwise.

And here is a VB example

in a module:
Public Declare Function InternetGetConnectedState Lib "wininet" (lpdwFlags As Long, ByVal dwReserved As Long) As Boolean

in a form:
Private Sub Command1_Click()
Dim flags As Long
Dim result As Boolean

result = InternetGetConnectedState(flags, 0)
If result Then
Print "Connected to the Internet"
Print "Not Connected to the Internet"
End If

If flags And INTERNET_CONNECTION_MODEM Then Print "Connection Via Modem"
If flags And INTERNET_CONNECTION_LAN Then Print "Connection Via LAN"
If flags And INTERNET_CONNECTION_PROXY Then Print "Connection uses a Proxy"
If flags And INTERNET_CONNECTION_MODEM_BUSY Then Print "Connection Via Modem but modem is busy"
End Sub

The idea of having a sepatate thread is a good one, though.
Posted on 2001-12-03 03:47:39 by peterverstappen

InternetGetConnectedState is actually a real API

Yep, you spelled it wrong in your first post, thats why i couldn't find anything in my msdn when i put that name in ;)

Bear in mind that by using that function, the only constant in the pdwFlags field that could possibly guarantee that you have a connection is the INTERNET_CONNECTION_LAN value, and even then that is no guarantee that the network is currently connected. I would suggest that you check out the function InternetCheckConnection(), it may be more what you are after.
Posted on 2001-12-03 04:13:25 by sluggy
Posted on 2001-12-03 04:17:05 by peterverstappen