For a very long time, I use this tool to search for my internal and external ip-address :
- Code: Select all Expand view
******************************************************************************
#INCLUDE "FIVEWIN.CH"
#DEFINE DEFAULT(xVar,xVal) xVar=IF(xVar=NIL,xVal,xVar)
******************************************************************************
FUNCTION IP_ADRES(nSec)
LOCAL oHttp
LOCAL cVar1 := ""
LOCAL cVar2 := ""
LOCAL cSec := 0
LOCAL cIPADRES1 := "www.dnsstuff.com/docs/ipall"
LOCAL cIPADRES2 := "Your IP Address: <strong>"
LOCAL cIPADRES3 := "</strong>"
DEFAULT(nSec,"0")
cSec := VAL(nSec)
WsaStartUp()
cVar1 := GetHostByName(GetHostName())
WsaCleanUp()
oHttp := CreateObject("winhttp.winhttprequest.5.1")
oHttp:Open("GET","http://"+ALLTRIM(cIPADRES1),.f.)
oHttp:Send()
cVar2 := oHttp:ResponseText()
cVar2 := StrExtract(cVar2,ALLTRIM(cIPADRES2),ALLTRIM(cIPADRES3))
IF cSec = 0
MsgAlert(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),""),"Message")
ELSE
MsgWait(IF(!EMPTY(cVar1),"Your current internal ip-address is : "+ALLTRIM(cVar1)+IF(!EMPTY(cVAR2)," - ",""),"") + IF(!EMPTY(cVar2),"Your current external ip-address is : "+ALLTRIM(cVar2),""),"Message",cSec)
ENDIF
QUIT
RETURN(.T.)
******************************************************************************
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)
******************************************************************************
FUNCTION OleInvoke(hObj,cMethod,uParam)
#IFNDEF __XHARBOUR__
RETURN __ObjSendMsg(TOleAuto():New(hObj),cMethod,uParam)
#ELSE
LOCAL aParams := hb_aParams()
aParams[1] := TOleAuto():New(hObj)
RETURN hb_execFromArray(@__ObjSendMsg(),aParams)
#ENDIF
******************************************************************************
FUNCTION OleSetProperty(hObj,cPropName,uValue)
RETURN __ObjSendMsg(TOleAuto():New(hObj),"_" + cPropName,uValue)
******************************************************************************
FUNCTION OleGetProperty(hObj,cPropName)
RETURN __ObjSendMsg(TOleAuto():New(hObj),cPropName)
******************************************************************************
Anyone who knows what is wrong ?
Thank you in advance for any help.