SiteMap  | About    

Checking Internet Connection

The Microsoft WinINet API enables applications to access standard Internet protocols, such as FTP and HTTP.

Many of you want to know if a computer has an active Internet connection before trying to connect to the internet using some communication interface. We can determine it by using one of WinINet function for check the status of internet connection in a computer.

InternetGetConnectedState function retrieves the connected state of the local system. A return value of TRUE from InternetGetConnectedState indicates that at least one connection to the Internet is available.

Imports System.Runtime.InteropServices

Public Class Form1

	Private Declare Function InternetGetConnectedState Lib "wininet" (ByRef conn As Long, ByVal val As Long) As Boolean

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		Dim Out As Integer
		If InternetGetConnectedState(Out, 0) = True Then
			MsgBox("Connected !")
			MsgBox("Not Connected !")
		End If
	End Sub

End Class (C) 2019    Founded by raps mk
All Rights Reserved. All other trademarks are property of their respective owners.