Caradeath
Messages postés2Date d'inscriptionmardi 16 septembre 2003StatutMembreDernière intervention17 septembre 2003
-
17 sept. 2003 à 20:29
pickatshou
Messages postés4Date d'inscriptionvendredi 6 juin 2008StatutMembreDernière intervention16 novembre 2012
-
8 mars 2013 à 12:47
Cette discussion concerne un article du site. Pour la consulter dans son contexte d'origine, cliquez sur le lien ci-dessous.
Permet de savoir son adresse IP publique
Reste plus qu'à mettre ca dans un joli thread
Appellez get_ip() pour avoir le résultat
[vbnet]
'Takes in website HTML, looks for a valid IP address (if a website is put in the list that displays
'some other IP address first, it WILL NOT know the difference)
Private Function get_ip() As String
Dim url As String
Try
'This is the responce from another function
url = GetSource()
Catch ex As Exception
MsgBox("There was a problem getting IP address, check URL list file, or your connection")
Return ""
End Try
'Regular expression to check for valid IP
Dim r As New System.Text.RegularExpressions.Regex("\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b")
Dim m As System.Text.RegularExpressions.Match = r.Match(url)
Dim ma As System.Text.RegularExpressions.Match
'Extracts just the matching string
ma = r.Match(url)
Return ma.Value.ToString
End Function
Private Function GetSource() As String
'This just downloads the contents of a webpage. I have an array of the websites that I load in from an XML file, you can make your own list
'The previous code will work on the ones already posted above.
Dim HtmlCode As String
Dim list As New WebClient
Dim temp As Byte()
temp = list.DownloadData("http://checkip.dyndns.org/")
HtmlCode = System.Text.Encoding.ASCII.GetString(temp)
Return HtmlCode
End Function
/vbnet
bizmoute
Messages postés29Date d'inscriptionvendredi 21 mars 2003StatutMembreDernière intervention21 novembre 2008 6 août 2006 à 22:58
mais si tu es sur un "router" (comme IOULOS), je ne suis pas sur que le résultat va te plaire...
à moins d'initialiser une connection externe au réseau local, je ne crois pas qu'il soit possible de déterminer l'adresse do coté WAN car c'est le router qui détient cette information.
You can't get the public IP address of your router because you are not in the good side because only another computer out of your lan can see the router IP Address. There is two common solutions :
1/ By Program : Use a site lik http://www.whatismyip.com/ (ther are several sites like this one) to get an html file and parse it with a regular expression parser to get the IP Address
2/ By Program : if you can get the status page of your router, then get this html file and parse it with a regular expression parser to get the IP Address
Et si tu ne t'y retrouve pas trop en anglais, en bref ca dit que la solution est logicielle... Exemple : utiliser une page comme http://www.whatismyip.com et "parser" le contenu recu afin de ne récupérer que l'adresse. ou encore accéder à la page html de configuration de ton router par programmation.
ronanry
Messages postés190Date d'inscriptionlundi 25 novembre 2002StatutMembreDernière intervention22 décembre 2009 20 nov. 2003 à 18:44
sauf erreur tu n'a pas le type wan partout.....en particulier en 56Ko....enfin je pense;......
cs_ioulos
Messages postés1Date d'inscriptionjeudi 9 janvier 2003StatutMembreDernière intervention13 octobre 2003 13 oct. 2003 à 17:26
Oui ca marche sauf que c'est l'ip LOCAL (puisque j'ai un réseaux chez moi ) ,et moi j'aimerai avoir l'ip INTERNET.
Donc je pense qu'il faudrait acceder aux informations des cartes réseaux pour connaitre leurs ip et ainsi selectionné celui qui est du type WAN.
Non?
Je pense que c'est avec l'espace de nom "system.management" qu'on peut faire çà!
Poly Progr@ms
Messages postés8Date d'inscriptiondimanche 21 septembre 2003StatutMembreDernière intervention25 janvier 2005 26 sept. 2003 à 20:46
pour la premiere : fo mettre un composant Winsock (Microsoft Winsock Controls 6 dans Ajout de composant)
pour la deuxieme :c du vb .net pas du vb 6 :p c pour ca que ca marche po
lucky2222
Messages postés92Date d'inscriptiondimanche 14 juillet 2002StatutMembreDernière intervention 2 octobre 2006 23 sept. 2003 à 12:33
salut les pro!
je suis un leune trou duc, qui n'y connait pas grand chose! alors j'ai copier coller dans une form, et les deux solutions ne marchent pas avec moi!!! Sniffff qu'ai je oublié? ou que faut il rajouter pour que ca marche vraiment?
Private Sub Form_Load()
Winsock1.Connect
MsgBox "ton ip est " & Winsock1.localip & " Good !"
End Sub
reponse un objet est requis et pou
Private Sub Form_Load()
Dim h As System.Net.IP
HostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName)
strMonIp = CType(h.AddressList.GetValue(0), System.Net.IPAddress).ToString
Label1.Caption = strMonIp
End Sub
type nom defini pour la zone "Dim h As System.Net.IP"
cs_Arknoth
Messages postés96Date d'inscriptionjeudi 2 janvier 2003StatutMembreDernière intervention22 août 2004 19 sept. 2003 à 21:43
faux son code fait bien 2 lignes, c juste le retour à la ligne auto chi fait 4^^
Tilois
Messages postés721Date d'inscriptiondimanche 10 juin 2001StatutMembreDernière intervention27 mars 20117 17 sept. 2003 à 20:56
Caradeath>ouaip mais toi tu est obligé d'ajouter un composant sur ta feuille, lui pas !! NA
Caradeath
Messages postés2Date d'inscriptionmardi 16 septembre 2003StatutMembreDernière intervention17 septembre 2003 17 sept. 2003 à 20:29
euh
Winsock1.connect
Msgbox "ton ip est " & Winsock1.localip & " Good !"
Aurait eté moins long :)
et ce code la fais vraiment deux ligne, le tiens 4 :)
8 mars 2013 à 12:47
6 août 2006 à 23:28
Merci à _Millsy
Testée et fonctionne avec .NET 2.0
Permet de savoir son adresse IP publique
Reste plus qu'à mettre ca dans un joli thread
Appellez get_ip() pour avoir le résultat
[vbnet]
'Takes in website HTML, looks for a valid IP address (if a website is put in the list that displays
'some other IP address first, it WILL NOT know the difference)
Private Function get_ip() As String
Dim url As String
Try
'This is the responce from another function
url = GetSource()
Catch ex As Exception
MsgBox("There was a problem getting IP address, check URL list file, or your connection")
Return ""
End Try
'Regular expression to check for valid IP
Dim r As New System.Text.RegularExpressions.Regex("\b(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b")
Dim m As System.Text.RegularExpressions.Match = r.Match(url)
Dim ma As System.Text.RegularExpressions.Match
'Extracts just the matching string
ma = r.Match(url)
Return ma.Value.ToString
End Function
Private Function GetSource() As String
'This just downloads the contents of a webpage. I have an array of the websites that I load in from an XML file, you can make your own list
'The previous code will work on the ones already posted above.
Dim HtmlCode As String
Dim list As New WebClient
Dim temp As Byte()
temp = list.DownloadData("http://checkip.dyndns.org/")
HtmlCode = System.Text.Encoding.ASCII.GetString(temp)
Return HtmlCode
End Function
/vbnet
6 août 2006 à 22:58
1 ligne?
mais si tu es sur un "router" (comme IOULOS), je ne suis pas sur que le résultat va te plaire...
à moins d'initialiser une connection externe au réseau local, je ne crois pas qu'il soit possible de déterminer l'adresse do coté WAN car c'est le router qui détient cette information.
Réponse trouvé ici pour toi IOULOS :
http://www.experts-exchange.com/Web/Q_20997692.html
Comment from ChristianRocher
Date: 05/21/2004 08:18AM PDT
Comment
You can't get the public IP address of your router because you are not in the good side because only another computer out of your lan can see the router IP Address. There is two common solutions :
1/ By Program : Use a site lik http://www.whatismyip.com/ (ther are several sites like this one) to get an html file and parse it with a regular expression parser to get the IP Address
2/ By Program : if you can get the status page of your router, then get this html file and parse it with a regular expression parser to get the IP Address
Et si tu ne t'y retrouve pas trop en anglais, en bref ca dit que la solution est logicielle... Exemple : utiliser une page comme http://www.whatismyip.com et "parser" le contenu recu afin de ne récupérer que l'adresse. ou encore accéder à la page html de configuration de ton router par programmation.
20 nov. 2003 à 18:44
13 oct. 2003 à 17:26
Donc je pense qu'il faudrait acceder aux informations des cartes réseaux pour connaitre leurs ip et ainsi selectionné celui qui est du type WAN.
Non?
Je pense que c'est avec l'espace de nom "system.management" qu'on peut faire çà!
26 sept. 2003 à 20:46
pour la deuxieme :c du vb .net pas du vb 6 :p c pour ca que ca marche po
23 sept. 2003 à 12:33
je suis un leune trou duc, qui n'y connait pas grand chose! alors j'ai copier coller dans une form, et les deux solutions ne marchent pas avec moi!!! Sniffff qu'ai je oublié? ou que faut il rajouter pour que ca marche vraiment?
Private Sub Form_Load()
Winsock1.Connect
MsgBox "ton ip est " & Winsock1.localip & " Good !"
End Sub
reponse un objet est requis et pou
Private Sub Form_Load()
Dim h As System.Net.IP
HostEntry = System.Net.Dns.GetHostByName(System.Net.Dns.GetHostName)
strMonIp = CType(h.AddressList.GetValue(0), System.Net.IPAddress).ToString
Label1.Caption = strMonIp
End Sub
type nom defini pour la zone "Dim h As System.Net.IP"
19 sept. 2003 à 21:43
17 sept. 2003 à 20:56
17 sept. 2003 à 20:29
Winsock1.connect
Msgbox "ton ip est " & Winsock1.localip & " Good !"
Aurait eté moins long :)
et ce code la fais vraiment deux ligne, le tiens 4 :)