VB5 Connection status

Hopefully someone knows this and will answer even though the point offering is low (I'm practically out at the moment).
How do you make your program recodnize when windows is connected to the net so it can auto launch from the task bar and remain dormant if your system is not connected?

Public Function ActiveConnection() As Boolean
' *** How can I detect if there is an active internet connection?
' *** For programs that rely on connecting to the internet,
' *** it is very useful to know whether or not the computer has an active connection.
' *** Whenever Windows logs on to a dial-up connection, it changes a value in the registry.

'Here is an example of how to use the ActiveConnection function.
'
'If ActiveConnection = True Then
' Call MsgBox("You have an active connection.", vbInformation)
'Else
' Call MsgBox("You have no active connections.", vbInformation)
'End If

Dim hKey As Long
Dim lpSubKey As String
Dim phkResult As Long
Dim lpValueName As String
Dim lpReserved As Long
Dim lpType As Long
Dim lpData As Long
Dim lpcbData As Long
Dim nRet As Long

an easyer way to do this will be to use the internet transfer control and try to connect to your application server (or any other server you want to work with.)
when you get a response , you are connected.
you will want to use error trapping and not display a message if you find out you're not connected.
with this control you can even set the timeout period for you connection trials.

That control isn't that great from what I've seen, and constantly sending out winsock requests to check the status and using error trapping is taxing on the system resources where as the code provided by waty simply grabs the connect value from the registry which uses practically no resources and doesn't require a winsock control to even be loaded...plus it's API so it's very quick. But thanks for the input.