r0m
Messages postés3Date d'inscriptionsamedi 2 avril 2005StatutMembreDernière intervention 3 avril 2005
-
3 avril 2005 à 14:59
medelidrissi
Messages postés180Date d'inscriptionjeudi 21 août 2003StatutMembreDernière intervention26 novembre 2007
-
4 avril 2005 à 00:14
Bonjour amis codeur !
Je réalise un logiciel qui donne des statistiques de connection internet et je suis face a un probleme impossible de savoir comment affichier le nom de la connection encours donc j'ai besoin de votre aide !
Ce serai du genre
Connection en cours : (ici la connection active)
medelidrissi
Messages postés180Date d'inscriptionjeudi 21 août 2003StatutMembreDernière intervention26 novembre 20072 3 avril 2005 à 18:42
Bonjour r0m :
Sache qu'en Informatique, rien n'est impossible... mais... ce n'est pas toujours évident!
Pour tester ce code il faut créer un nouveau projet, une forme dans laquelle tu mettras un textebox nommé text1.
Option Explicit
Private Declare Function InternetGetConnectedStateEx Lib "wininet.dll" Alias "InternetGetConnectedStateExA" (lpdwFlags As Long, lpszConnectionName As Long, dwNameLen As Long, ByVal dwReserved As Long) As Long
Private Declare Function lstrcpy Lib "kernel32.dll" Alias "lstrcpyA" (ByVal lpString1 As String, ByVal lpString2 As Long) As Long
Private Declare Function lstrlen Lib "kernel32.dll" Alias "lstrlenA" (ByVal lpString As Any) As Long
Private Sub Form_Load()
Dim strConnectionName As String
Dim lNameLen As Long
Dim lRetVal As Long
Dim lPtr As Long
Dim lConnectionFlags As Long
Dim lNameLenPtr As Long
strConnectionName = Space(256)
lNameLen = 256
lPtr = StrPtr(strConnectionName)
lNameLenPtr = VarPtr(lNameLen)
lRetVal = InternetGetConnectedStateEx(lConnectionFlags, ByVal lPtr, ByVal lNameLen, 0&)
strConnectionName = StringFromPointer(lPtr)
Text1.Text = strConnectionName
End Sub
Private Function StringFromPointer(ByVal lPointer As Long) As String
Dim strTemp As String
Dim lRetVal As Long
strTemp = String$(lstrlen(ByVal lPointer), 0)
lRetVal = lstrcpy(ByVal strTemp, ByVal lPointer)
If lRetVal Then StringFromPointer = strTemp
End Function
Normalement si tout se déroule bien tu auras ton non de connexion dans le champ texte