Récupérer l'IP de sa connexion à interval régulier (toutes l
cs_lerak
Messages postés6Date d'inscriptiondimanche 10 novembre 2002StatutMembreDernière intervention20 mars 2006
-
10 nov. 2002 à 20:15
BasicInstinct
Messages postés1470Date d'inscriptionmardi 5 février 2002StatutMembreDernière intervention20 octobre 2014
-
15 nov. 2002 à 11:15
Bonjour,
J'ai lu sur le forum comment récupérer cet IP. Mais il est nécessaire à chaque fois de relancer le programme pour détecter un éventuel changement d'IP (notamment quand la connexion est interrompue, ou quand la connexion est relancée)
ya t-il moyen de rafraichir l'info winsock1.IPlocal, ou peut-être une api qui récupère cette info sans relancer le programme.
Merci
A voir également:
Récupérer l'IP de sa connexion à interval régulier (toutes l
BasicInstinct
Messages postés1470Date d'inscriptionmardi 5 février 2002StatutMembreDernière intervention20 octobre 201412 15 nov. 2002 à 11:15
Le code ci-dessous n'est evidement pas de moi, mais devrais repondre a ton probleme
Const MAXLEN_PHYSADDR = 8
Private Type MIB_IPNETROW
dwIndex As Long
dwPhysAddrLen As Long
bPhysAddr(0 To MAXLEN_PHYSADDR - 1) As Byte
dwAddr As Long
dwType As Long
End Type
Private Declare Function GetIpNetTable Lib "Iphlpapi" (pIpNetTable As Byte, pdwSize As Long, ByVal bOrder As Long) As Long
Private Declare Sub CopyMemory Lib "kernel32" Alias "RtlMoveMemory" (pDst As Any, pSrc As Any, ByVal ByteLen As Long)
Private Sub Form_Load()
'KPD-Team 2001
'URL: http://www.allapi.net/ 'E-Mail: KPDTeam@Allapi.net
Dim Listing() As MIB_IPNETROW, Ret As Long, Cnt As Long
Dim bBytes() As Byte, bTemp(0 To 3) As Byte
'set the graphics mode of this form to persistent
Me.AutoRedraw = True
'call the function to retrieve how many bytes are needed
GetIpNetTable ByVal 0&, Ret, False
'if it failed, exit the sub
If Ret <= 0 Then Exit Sub
'redimension our buffer
ReDim bBytes(0 To Ret - 1) As Byte
'retireve the data
GetIpNetTable bBytes(0), Ret, False
'copy the number of entries to the 'Ret' variable
CopyMemory Ret, bBytes(0), 4
'redimension the Listing
If Ret > 0 Then ReDim Listing(0 To Ret - 1) As MIB_IPNETROW
'show the data
Me.Print "Contents of address mapping table (items: " + CStr(Ret) + ")"
For Cnt = 0 To Ret - 1
CopyMemory Listing(Cnt), bBytes(4 + 24 * Cnt), 24
CopyMemory bTemp(0), Listing(Cnt).dwAddr, 4
Me.Print " Item " + CStr(Listing(Cnt).dwIndex)
Me.Print " address " + ConvertAddressToString(bTemp(), 4)
Me.Print " physical address " + ConvertAddressToString(Listing(Cnt).bPhysAddr, Listing(Cnt).dwPhysAddrLen)
Select Case Listing(Cnt).dwType
Case 4 'Static
Me.Print " type: Static"
Case 3 'Dynamic
Me.Print " type: Dynamic"
Case 2 'Invalid
Me.Print " type: Invalid"
Case 1 'Other
Me.Print " type: Other"
End Select
Next Cnt
End Sub
'converts a byte array to a string
Public Function ConvertAddressToString(bArray() As Byte, lLength As Long) As String
Dim Cnt As Long
For Cnt = 0 To lLength - 1
ConvertAddressToString = ConvertAddressToString + CStr(bArray(Cnt)) + "."
Next Cnt
ConvertAddressToString = Left$(ConvertAddressToString, Len(ConvertAddressToString) - 1)
End Function