******************************************************************************
* *
* Program : IPADRES.PRG *
* Author : DRIESSEN Michel *
* Date : 24/11/2011 - Ipadres - xHarbour *
* *
* Goal : Looking for internal en external IP-address *
* *
******************************************************************************
#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),""),"Take care")
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),""),"Take care",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)
******************************************************************************