Detecting internet connection.

in a class module ( or below the End Class statement of your Form ) ...
Code:
Public Class _Win32

    Public Enum Connection As Integer
        Connected = 1
        DisConnected = 0
    End Enum

    Public Declare Function InternetGetConnectedState Lib "wininet.dll" (Optional ByRef lpdwFlags As Integer = 0, Optional ByVal dwReserved As Integer = 0) As Connection

End Class
to use from a button_click on your Form ...
Code:
    Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
        If _Win32.InternetGetConnectedState = _Win32.Connection.Connected Then
            MessageBox.Show("you are connected to the net")
        Else
            MessageBox.Show("you are NOT connected to the net")
        End If
    End Sub
 
Back
Top