Someone provided me with this code to get the internal and external ip-address.
- Code: Select all Expand view
- FUNCTION IP_ADDRESS
LOCAL oHttp
LOCAL cVar1 := ""
LOCAL cVar2 := ""
WsaStartUp()
cVar1 := GetHostByName( GetHostName() )
WsaCleanUp()
TRY
oHttp := CreateObject("winhttp.winhttprequest.5.1")
oHttp:Open("GET","http://www.ip-adress.com/",.f.)
oHttp:Send()
cVar2 := oHttp:ResponseText()
cVar2 := StrExtract(cVar2,"My IP address: ","</h2>")
CATCH
END
RETURN(IF(!EMPTY(cVar1),"Your current internal IP-address is : " + ALLTRIM(cVar1) + ;
IF(!EMPTY(cVAR2),CHR(13)+CHR(13),""),"") + ;
IF(!EMPTY(cVar2),"Your current external IP-address is : "+ALLTRIM(cVar2),""))
******************************************************************************
STATIC FUNCTION StrExtract(cText,cAfter,cBefore)
LOCAL cRet := SUBSTR(cText,AT(cAfter,cText) + LEN(cAfter))
LOCAL n
IF (n := AT(cBefore,cRet)) > 0
cRet := LEFT(cRet,n - 1)
ENDIF
RETURN(cRet)
But since a few days ago, this code isn't working anymore.
Does anyone has any idea why ?
Thanks a lot in advance for any help.