Ecco come testare lo stato della connessione :
C# :
using System.Runtime.InteropServices ;
public class ConnectionState
{
[DllImport("wininet.dll")]
private extern static bool InternetGetConnectedState(out int Description, int ReservedValue);
public ConnectionState()
{
}
public static bool ConnessioneInternet( )//rileva se la macchina è on-line {
{
int Desc ;
return InternetGetConnectedState( out Desc, 0 ) ;
}
}
VB.Net :
Imports System.Runtime.InteropServices
Public Class ConnectionState
<DllImport("wininet.dll")> _
Private Shared Function InternetGetConnectedState(ByRef Description
As Integer, ByVal ReservedValue As Integer) As Boolean
End Function
Public Sub New()
End Sub
Public Shared Function ConnessioneInternet() As Boolean
Dim Desc As Integer
Return InternetGetConnectedState(Desc, 0)
End Function
End Class