Comment déterminer si l'ordinateur est connecté à Internet ?
Il suffit d'employer l'API InternetGetConnectedState qui retourne True si
l'ordinateur est connecté à Internet :
Private Declare Function InternetGetConnectedState Lib "wininet.dll"
(ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long
Private Sub Form_Load()
If InternetGetConnectedState(0&, 0&) Then
MsgBox "Vous êtes connecté à
Internet", vbInformation
Else
MsgBox "Vous n'êtes pas
connecté à Internet", vbInformation
End If
End Sub
Remarque : l'emploi de cette API requière la présence
d'Internet Explorer 4.0 (minimum) sur le poste. |