Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long Private Sub Form_Load() MsgBox "Is connected to the internet: " + CStr(IsConnected) End Sub Public Function IsConnected() As Boolean If InternetGetConnectedState(0&, 0&) = 1 Then IsConnected = True Else IsConnected = False End If End Function
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre questionPrivate Const INTERNET_CONNECTION_CONFIGURED = &H40 Private Const INTERNET_CONNECTION_LAN = &H2 Private Const INTERNET_CONNECTION_MODEM = &H1 Private Const INTERNET_CONNECTION_OFFLINE = &H20 Private Const INTERNET_CONNECTION_PROXY = &H4 Private Const INTERNET_RAS_INSTALLED = &H10 Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long Private Sub Form_Load() 'KPD-Team 2001 'URL: http://www.allapi.net/ 'E-Mail: KPDTeam@Allapi.net Dim Ret As Long Me.AutoRedraw = True 'retrieve the connection status InternetGetConnectedState Ret, 0& 'show the result If (Ret And INTERNET_CONNECTION_CONFIGURED) = INTERNET_CONNECTION_CONFIGURED Then Me.Print "Local system has a valid connection to the Internet, but it may or may not be currently connected." If (Ret And INTERNET_CONNECTION_LAN) = INTERNET_CONNECTION_LAN Then Me.Print "Local system uses a local area network to connect to the Internet." If (Ret And INTERNET_CONNECTION_MODEM) = INTERNET_CONNECTION_MODEM Then Me.Print "Local system uses a modem to connect to the Internet." If (Ret And INTERNET_CONNECTION_OFFLINE) = INTERNET_CONNECTION_OFFLINE Then Me.Print "Local system is in offline mode." If (Ret And INTERNET_CONNECTION_PROXY) = INTERNET_CONNECTION_PROXY Then Me.Print "Local system uses a proxy server to connect to the Internet." If (Ret And INTERNET_RAS_INSTALLED) = INTERNET_RAS_INSTALLED Then Me.Print "Local system has RAS installed." End Sub