machine that is running behind a router.
Does anyone know a clean way to do that?
I am using the code below, which works, but I am hoping there is a more
appropriate way than depending on the data from a website. Certainly
there should be a way to do it completely locally.
TIA,
Terry
Code: Select all
; Author: ricardo (based on older Forum code)
; Date: 11. October 2003
; -----------------------
; Modified by NoahPhense
; Date: 27. June 2004
; note: Thought I saw something like this somewhere, but couldn't
; find it, so I modified some old code. This code is meant
; to rip pages. So I'm just parsing the ripped page.
; -----------------------
; Modified by TerryHough
; Data: 27, June 2005
#INTERNET_FLAG_RELOAD = $80000000
Bytes.l = 84
Html.s = Space(84)
hInet.l = InternetOpen_("http://www.showmyip.com", 1, #NULL, #NULL, 0)
If hInet
hURL.l = InternetOpenUrl_(hInet, "http://www.showmyip.com", #NULL, 0, #INTERNET_FLAG_RELOAD, 0)
If hURL
If InternetReadFile_(hURL, @Html, Len(Html), @Bytes)
; Search the downloaded html code for the IP Address ----------
SearchString.s = "IP Address properties of your Internet Connection "
Pos = FindString(Html, SearchString, 1)
Html = RemoveString(Trim(Mid(Html, Pos, Len(SearchString) + 15)),SearchString)
Pos = FindString(Html," ",1)
If Pos
Html = Mid(Html,1,Pos-1)
EndIf
MessageRequester("IP Address",Html,#MB_ICONINFORMATION)
; -------------------------------------------------------------
InternetCloseHandle_(hURL)
Else
MessageRequester("Error","Couldn't read the IP Address html page",#MB_ICONERROR)
EndIf
Else
MessageRequester("Error","Couldn't read the designated URL",#MB_ICONERROR)
EndIf
InternetCloseHandle_(hInet)
Else
MessageRequester("Error","Couldn't connect to the Internet",#MB_ICONERROR)
EndIf
End