Bonjour,
Je cherche une méthode qui me permettrais de savoir si une connexion à internet est existante.
J'ai trouvé ce morceau de code sur Internet, mais ça fonctionne pas vraiment chez moi :
using System ; using System.Runtime ; using System.Runtime.InteropServices ;
public class InternetCS {
//Creating the extern function... [DllImport("wininet.dll")] private extern static bool InternetGetConnectedState( int out Description, int ReservedValue ) ;
//Creating a function that uses the API function... public static bool IsConnectedToInternet( ) {
int Desc ; return InternetGetConnectedState( out Desc, 0 ) ;
}
}
|
Quelqu'un pourrait t'il me dire pourquoi ça fontionne pas, ou alors me donner une autre méthode?
Merci d'avance aux réponses.
Bidou