FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Searching for internal and external ip-address - solved
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Searching for internal and external ip-address - solved
Posted: Tue Jan 15, 2013 12:56 PM
Hello,

For a very long time, I use this tool to search for my internal and external ip-address :
Code (fw): Select all Collapse
******************************************************************************
#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)

******************************************************************************
Since last week, this function isn't working anymore allthough I didn't change it a single character.

Anyone who knows what is wrong ?

Thank you in advance for any help.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Posts: 368
Joined: Sun May 31, 2009 06:25 PM
Re: Searching for internal and external ip-address
Posted: Tue Jan 15, 2013 01:26 PM

Change to:
LOCAL cIPADRES2 := [Your IP Address: <strong class="ipBlock">]

Regards,



André Dutheil

FWH 13.04 + HB 3.2 + MSVS 10
Posts: 1467
Joined: Mon Oct 10, 2005 11:26 AM
Re: Searching for internal and external ip-address - Solved
Posted: Tue Jan 15, 2013 02:00 PM

André,

Thank you very much.

Problem is solved.

Regards,

Michel D.
Genk (Belgium)


_____________________________________________________________________________________________

I use : FiveWin for (x)Harbour v. 25.12 - Harbour 3.2.0 (May 2025) - xHarbour Builder (January 2020) - Bcc773

Continue the discussion