Malgres toutes mes recherches sur ce forum, je n'ai pas trouvé un procédé
vba permettant de récupérer l'ip internet d'une machine faisant partie d'un
reseau.
En effet, je souhaite récupérer l'ip du style 81.66.229.131 et non le
192.168.0.1
Private Declare Function URLDownloadToFile Lib "urlmon" _ Alias "URLDownloadToFileA" _ (ByVal pCaller As Long, _ ByVal szURL As String, _ ByVal szFileName As String, _ ByVal dwReserved As Long, _ ByVal lpfnCB As Long) As Long
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _ Alias "DeleteUrlCacheEntryA" _ (ByVal lpszUrlName As String) As Long
Private Sub CommandButton1_Click() MsgBox "IP Publique : " & GetPublicIP() End Sub
Private Function GetPublicIP() Dim sSourceUrl As String Dim sLocalFile As String Dim hfile As Long Dim buff As String Dim pos1 As Long Dim pos2 As Long
'site returning IP address sSourceUrl = "http://vbnet.mvps.org/resources/tools/getpublicip.shtml" sLocalFile = "c:ip.txt"
'ensure this file does not exist in the cache Call DeleteUrlCacheEntry(sSourceUrl)
'download the public IP file, 'read into a buffer and delete If DownloadFile(sSourceUrl, sLocalFile) Then hfile = FreeFile Open sLocalFile For Input As #hfile buff = Input$(LOF(hfile), hfile) Close #hfile 'look for the IP line pos1 = InStr(buff, "var ip =") 'if found, If pos1 Then 'get position of first and last single 'quotes around address (e.g. '11.22.33.44') pos1 = InStr(pos1 + 1, buff, "'", vbTextCompare) + 1 pos2 = InStr(pos1 + 1, buff, "'", vbTextCompare) '- 1 'return the IP address GetPublicIP = Mid$(buff, pos1, pos2 - pos1) Else GetPublicIP = "(unable to parse IP)" End If Kill sLocalFile Else GetPublicIP = "(unable to access shtml page)" End If End Function
Private Function DownloadFile(ByVal sURL As String, _ ByVal sLocalFile As String) As Boolean DownloadFile = URLDownloadToFile(0, sURL, sLocalFile, 0, 0) = ERROR_SUCCESS End Function
Bonjour à tous
Malgres toutes mes recherches sur ce forum, je n'ai pas trouvé un procédé vba permettant de récupérer l'ip internet d'une machine faisant partie d'un reseau. En effet, je souhaite récupérer l'ip du style 81.66.229.131 et non le 192.168.0.1
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _
Alias "DeleteUrlCacheEntryA" _
(ByVal lpszUrlName As String) As Long
Private Sub CommandButton1_Click()
MsgBox "IP Publique : " & GetPublicIP()
End Sub
Private Function GetPublicIP()
Dim sSourceUrl As String
Dim sLocalFile As String
Dim hfile As Long
Dim buff As String
Dim pos1 As Long
Dim pos2 As Long
'site returning IP address
sSourceUrl = "http://vbnet.mvps.org/resources/tools/getpublicip.shtml"
sLocalFile = "c:ip.txt"
'ensure this file does not exist in the cache
Call DeleteUrlCacheEntry(sSourceUrl)
'download the public IP file,
'read into a buffer and delete
If DownloadFile(sSourceUrl, sLocalFile) Then
hfile = FreeFile
Open sLocalFile For Input As #hfile
buff = Input$(LOF(hfile), hfile)
Close #hfile
'look for the IP line
pos1 = InStr(buff, "var ip =")
'if found,
If pos1 Then
'get position of first and last single
'quotes around address (e.g. '11.22.33.44')
pos1 = InStr(pos1 + 1, buff, "'", vbTextCompare) + 1
pos2 = InStr(pos1 + 1, buff, "'", vbTextCompare) '- 1
'return the IP address
GetPublicIP = Mid$(buff, pos1, pos2 - pos1)
Else
GetPublicIP = "(unable to parse IP)"
End If
Kill sLocalFile
Else
GetPublicIP = "(unable to access shtml page)"
End If
End Function
Private Function DownloadFile(ByVal sURL As String, _
ByVal sLocalFile As String) As Boolean
DownloadFile = URLDownloadToFile(0, sURL, sLocalFile, 0, 0) =
ERROR_SUCCESS
End Function
Bonjour à tous
Malgres toutes mes recherches sur ce forum, je n'ai pas trouvé un procédé
vba permettant de récupérer l'ip internet d'une machine faisant partie d'un
reseau.
En effet, je souhaite récupérer l'ip du style 81.66.229.131 et non le
192.168.0.1
Private Declare Function URLDownloadToFile Lib "urlmon" _ Alias "URLDownloadToFileA" _ (ByVal pCaller As Long, _ ByVal szURL As String, _ ByVal szFileName As String, _ ByVal dwReserved As Long, _ ByVal lpfnCB As Long) As Long
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _ Alias "DeleteUrlCacheEntryA" _ (ByVal lpszUrlName As String) As Long
Private Sub CommandButton1_Click() MsgBox "IP Publique : " & GetPublicIP() End Sub
Private Function GetPublicIP() Dim sSourceUrl As String Dim sLocalFile As String Dim hfile As Long Dim buff As String Dim pos1 As Long Dim pos2 As Long
'site returning IP address sSourceUrl = "http://vbnet.mvps.org/resources/tools/getpublicip.shtml" sLocalFile = "c:ip.txt"
'ensure this file does not exist in the cache Call DeleteUrlCacheEntry(sSourceUrl)
'download the public IP file, 'read into a buffer and delete If DownloadFile(sSourceUrl, sLocalFile) Then hfile = FreeFile Open sLocalFile For Input As #hfile buff = Input$(LOF(hfile), hfile) Close #hfile 'look for the IP line pos1 = InStr(buff, "var ip =") 'if found, If pos1 Then 'get position of first and last single 'quotes around address (e.g. '11.22.33.44') pos1 = InStr(pos1 + 1, buff, "'", vbTextCompare) + 1 pos2 = InStr(pos1 + 1, buff, "'", vbTextCompare) '- 1 'return the IP address GetPublicIP = Mid$(buff, pos1, pos2 - pos1) Else GetPublicIP = "(unable to parse IP)" End If Kill sLocalFile Else GetPublicIP = "(unable to access shtml page)" End If End Function
Private Function DownloadFile(ByVal sURL As String, _ ByVal sLocalFile As String) As Boolean DownloadFile = URLDownloadToFile(0, sURL, sLocalFile, 0, 0) = ERROR_SUCCESS End Function
Bonjour à tous
Malgres toutes mes recherches sur ce forum, je n'ai pas trouvé un procédé vba permettant de récupérer l'ip internet d'une machine faisant partie d'un reseau. En effet, je souhaite récupérer l'ip du style 81.66.229.131 et non le 192.168.0.1
Private Declare Function URLDownloadToFile Lib "urlmon" _ Alias "URLDownloadToFileA" _ (ByVal pCaller As Long, _ ByVal szURL As String, _ ByVal szFileName As String, _ ByVal dwReserved As Long, _ ByVal lpfnCB As Long) As Long
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _ Alias "DeleteUrlCacheEntryA" _ (ByVal lpszUrlName As String) As Long
Private Sub CommandButton1_Click() MsgBox "IP Publique : " & GetPublicIP() End Sub
Private Function GetPublicIP() Dim sSourceUrl As String Dim sLocalFile As String Dim hfile As Long Dim buff As String Dim pos1 As Long Dim pos2 As Long
'site returning IP address sSourceUrl = "http://vbnet.mvps.org/resources/tools/getpublicip.shtml" sLocalFile = "c:ip.txt"
'ensure this file does not exist in the cache Call DeleteUrlCacheEntry(sSourceUrl)
'download the public IP file, 'read into a buffer and delete If DownloadFile(sSourceUrl, sLocalFile) Then hfile = FreeFile Open sLocalFile For Input As #hfile buff = Input$(LOF(hfile), hfile) Close #hfile 'look for the IP line pos1 = InStr(buff, "var ip =") 'if found, If pos1 Then 'get position of first and last single 'quotes around address (e.g. '11.22.33.44') pos1 = InStr(pos1 + 1, buff, "'", vbTextCompare) + 1 pos2 = InStr(pos1 + 1, buff, "'", vbTextCompare) '- 1 'return the IP address GetPublicIP = Mid$(buff, pos1, pos2 - pos1) Else GetPublicIP = "(unable to parse IP)" End If Kill sLocalFile Else GetPublicIP = "(unable to access shtml page)" End If End Function
Private Function DownloadFile(ByVal sURL As String, _ ByVal sLocalFile As String) As Boolean DownloadFile = URLDownloadToFile(0, sURL, sLocalFile, 0, 0) = ERROR_SUCCESS End Function
Bonjour à tous
Malgres toutes mes recherches sur ce forum, je n'ai pas trouvé un procédé vba permettant de récupérer l'ip internet d'une machine faisant partie d'un reseau. En effet, je souhaite récupérer l'ip du style 81.66.229.131 et non le 192.168.0.1
Auriez-vous une solution pour cela ?
Merci à vous tous
Cordialement Michel
-- Cordialement,
Jacques.
GENIALLLLLLLL
Merci Beaucoup
Michel
"Jacques93" <jacques@Nospam> a écrit dans le message de news:
ubkjMwATGHA.4368@TK2MSFTNGP14.phx.gbl...
Private Declare Function URLDownloadToFile Lib "urlmon" _
Alias "URLDownloadToFileA" _
(ByVal pCaller As Long, _
ByVal szURL As String, _
ByVal szFileName As String, _
ByVal dwReserved As Long, _
ByVal lpfnCB As Long) As Long
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _
Alias "DeleteUrlCacheEntryA" _
(ByVal lpszUrlName As String) As Long
Private Sub CommandButton1_Click()
MsgBox "IP Publique : " & GetPublicIP()
End Sub
Private Function GetPublicIP()
Dim sSourceUrl As String
Dim sLocalFile As String
Dim hfile As Long
Dim buff As String
Dim pos1 As Long
Dim pos2 As Long
'site returning IP address
sSourceUrl = "http://vbnet.mvps.org/resources/tools/getpublicip.shtml"
sLocalFile = "c:ip.txt"
'ensure this file does not exist in the cache
Call DeleteUrlCacheEntry(sSourceUrl)
'download the public IP file,
'read into a buffer and delete
If DownloadFile(sSourceUrl, sLocalFile) Then
hfile = FreeFile
Open sLocalFile For Input As #hfile
buff = Input$(LOF(hfile), hfile)
Close #hfile
'look for the IP line
pos1 = InStr(buff, "var ip =")
'if found,
If pos1 Then
'get position of first and last single
'quotes around address (e.g. '11.22.33.44')
pos1 = InStr(pos1 + 1, buff, "'", vbTextCompare) + 1
pos2 = InStr(pos1 + 1, buff, "'", vbTextCompare) '- 1
'return the IP address
GetPublicIP = Mid$(buff, pos1, pos2 - pos1)
Else
GetPublicIP = "(unable to parse IP)"
End If
Kill sLocalFile
Else
GetPublicIP = "(unable to access shtml page)"
End If
End Function
Private Function DownloadFile(ByVal sURL As String, _
ByVal sLocalFile As String) As Boolean
DownloadFile = URLDownloadToFile(0, sURL, sLocalFile, 0, 0) =
ERROR_SUCCESS
End Function
Bonjour à tous
Malgres toutes mes recherches sur ce forum, je n'ai pas trouvé un procédé
vba permettant de récupérer l'ip internet d'une machine faisant partie
d'un reseau.
En effet, je souhaite récupérer l'ip du style 81.66.229.131 et non le
192.168.0.1
Private Declare Function URLDownloadToFile Lib "urlmon" _ Alias "URLDownloadToFileA" _ (ByVal pCaller As Long, _ ByVal szURL As String, _ ByVal szFileName As String, _ ByVal dwReserved As Long, _ ByVal lpfnCB As Long) As Long
Private Declare Function DeleteUrlCacheEntry Lib "Wininet.dll" _ Alias "DeleteUrlCacheEntryA" _ (ByVal lpszUrlName As String) As Long
Private Sub CommandButton1_Click() MsgBox "IP Publique : " & GetPublicIP() End Sub
Private Function GetPublicIP() Dim sSourceUrl As String Dim sLocalFile As String Dim hfile As Long Dim buff As String Dim pos1 As Long Dim pos2 As Long
'site returning IP address sSourceUrl = "http://vbnet.mvps.org/resources/tools/getpublicip.shtml" sLocalFile = "c:ip.txt"
'ensure this file does not exist in the cache Call DeleteUrlCacheEntry(sSourceUrl)
'download the public IP file, 'read into a buffer and delete If DownloadFile(sSourceUrl, sLocalFile) Then hfile = FreeFile Open sLocalFile For Input As #hfile buff = Input$(LOF(hfile), hfile) Close #hfile 'look for the IP line pos1 = InStr(buff, "var ip =") 'if found, If pos1 Then 'get position of first and last single 'quotes around address (e.g. '11.22.33.44') pos1 = InStr(pos1 + 1, buff, "'", vbTextCompare) + 1 pos2 = InStr(pos1 + 1, buff, "'", vbTextCompare) '- 1 'return the IP address GetPublicIP = Mid$(buff, pos1, pos2 - pos1) Else GetPublicIP = "(unable to parse IP)" End If Kill sLocalFile Else GetPublicIP = "(unable to access shtml page)" End If End Function
Private Function DownloadFile(ByVal sURL As String, _ ByVal sLocalFile As String) As Boolean DownloadFile = URLDownloadToFile(0, sURL, sLocalFile, 0, 0) = ERROR_SUCCESS End Function
Bonjour à tous
Malgres toutes mes recherches sur ce forum, je n'ai pas trouvé un procédé vba permettant de récupérer l'ip internet d'une machine faisant partie d'un reseau. En effet, je souhaite récupérer l'ip du style 81.66.229.131 et non le 192.168.0.1