Vérification de l'accés à internet

Bowlman Messages postés 21 Date d'inscription mardi 8 mai 2001 Statut Membre Dernière intervention 18 février 2010 - 14 mai 2003 à 20:31
cs_marco62118 Messages postés 176 Date d'inscription mercredi 7 avril 2004 Statut Membre Dernière intervention 1 avril 2013 - 8 avril 2009 à 12:51
Comment vérifier si je suis connecté à internet avec mon routeur sous VB?
Je voudrais créer un prog qui vérifie si je suis en ligne
- Si c'est le cas, rien faire
- Si ce n'est pas le cas envoyer un message.
(Pour le début.Ajout d'options plus tard. )
Merci

Bowlman vous remercie de votre attention
http://www.bowlman.be.tf

6 réponses

Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
14 mai 2003 à 21:14
MERCI DE REGARDE SUR LE FORUM , AVANT DE POSER UNE QUESTION !!!

c'est une question récurente , ici !!

une API sers a donner l'etat de la connexion internet. Ensuite , il suffit de regarder la valeur retournee , en fonction de differentes constantes.....

http://www.bowlman.be.tf
0
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
14 mai 2003 à 23:25
ou bien , plus simplement :
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

-----------------------------------------------------------------------
By Renfield

thomas_reynald@msn.com

Aucune touche n'a été bléssée lors de la saisie de ce texte..........
0
Bowlman Messages postés 21 Date d'inscription mardi 8 mai 2001 Statut Membre Dernière intervention 18 février 2010
18 mai 2003 à 17:51
Ok ca vérifie quand c avec un modem branché direct mais pas via réseau et routeur!
Ce qu'il faudrais c vérifier si j'accede à 1 site.
Meme 3 site comme ca si 1 est down alors,...
Il vérifie le suivant
et me dis si je suis connecté!
Merci de l'aide mais ca ne suffit pas Dsl.

Bowlman vous remercie de votre attention
http://www.bowlman.be.tf
0
Bowlman Messages postés 21 Date d'inscription mardi 8 mai 2001 Statut Membre Dernière intervention 18 février 2010
18 mai 2003 à 17:54
Ok si c bon. merci!!!

Bowlman vous remercie de votre attention
http://www.bowlman.be.tf
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
Renfield Messages postés 17287 Date d'inscription mercredi 2 janvier 2002 Statut Modérateur Dernière intervention 27 septembre 2021 74
18 mai 2003 à 21:18
ok , voici un code qui donne plus d'infos.....
(from allapi.net)

Private 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

-----------------------------------------------------------------------
By Renfield

thomas_reynald@msn.com

Aucune touche n'a été bléssée lors de la saisie de ce texte..........
0
cs_marco62118 Messages postés 176 Date d'inscription mercredi 7 avril 2004 Statut Membre Dernière intervention 1 avril 2013 1
8 avril 2009 à 12:51
bonjour
je me permets de m'imisser dans ce post
je ne comprends pas bien, Renfield, ta vérification :"If (Ret And INTERNET_CONNECTION_CONFIGURED) = INTERNET_CONNECTION_CONFIGURED "??
si j'ai bien compris l'api Ret est un retour de l'api et si internet a une connection configurée l'api retourne la valeur &H40 soit 64 alors pourquoi ne pas simplement écrire : if If Ret = INTERNET_CONNECTION_CONFIGURED  then ....

De plus un autre pb je suis connecté avec un modem adsl et la valeur retourné par l'API est 81
qu'en penses tu?

merci d'avance
0
Rejoignez-nous