Ma è possibile chiudere una connessione ADSL ?
Ritengo di no, almeno che non lo si faccia spegnendo (fisicamente) il dispositivo.
O Sbaglio ?
Comunque per testare lo stato della connessione prova questo codice:
Da inserire in un modulo bas:
codice:
Public Const CONNECT_LAN As Long = &H2
Public Const CONNECT_MODEM As Long = &H1
Public Const CONNECT_PROXY As Long = &H4
Public Const CONNECT_OFFLINE As Long = &H20
Public Const CONNECT_CONFIGURED As Long = &H40
Public Function IsConnected(Optional ByRef sConnType As String) As Boolean
Dim bConnected As Long
Dim dwflags As Long
Dim WebTest As Boolean
sConnType = ""
bConnected = InternetGetConnectedState(dwflags, 0&)
Select Case bConnected
Case dwflags And CONNECT_LAN:
sConnType = "LAN"
Case dwflags And CONNECT_MODEM:
sConnType = "Modem"
Case dwflags And CONNECT_PROXY:
sConnType = "Proxy"
Case dwflags And CONNECT_OFFLINE:
sConnType = "Offline"
Case dwflags And CONNECT_CONFIGURED:
sConnType = "Configured"
Case Else:
sConnType = "Remote"
End Select
IsConnected = bConnected
End Function
Da inserire nella Frm:
codice:
Option Explicit
Private Sub Test_Click()
Dim sMsg As String
Dim sConnType As String
If IsConnected(sConnType) Then
sMsg = "Connesso ad Internet tramite " & sConnType & "."
Else: sMsg = "Connessione ad Internet chiusa."
End If
MsgBox sMsg, vbOKOnly, "Stato della connessione Internet"
End Sub
Ciao, e fammi sapere.