IP address.

Moderator: Rathinagiri

Post Reply
User avatar
zolysoftsolutions
Posts: 101
Joined: Wed Feb 29, 2012 3:33 am
Location: Gyulakuta, Erdélyország
Contact:

IP address.

Post by zolysoftsolutions » Sun Mar 31, 2013 12:10 pm

Hello,

Is possibble to read the IP address allocated by ISP?
The internal IP address is in windows registry, but the external not.
I need to read to a variable in some way the IP address like the "whatismyipadress.com" retourned.
By example on local machine I have 192.168.1.6 and the IP allocated by ISP is 89.192.166.27 (retourned by whatismyipadress.com)

Best regards,
Zoli B.
_______________________________
Open eyes for you!

User avatar
esgici
Posts: 4346
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 234 times
Been thanked: 80 times
Contact:

Post by esgici » Sun Mar 31, 2013 1:23 pm

zolysoftsolutions wrote:Hello,

Is possibble to read the IP address allocated by ISP?
The internal IP address is in windows registry, but the external not.
I need to read to a variable in some way the IP address like the "whatismyipadress.com" retourned.
By example on local machine I have 192.168.1.6 and the IP allocated by ISP is 89.192.166.27 (retourned by whatismyipadress.com)

Best regards,
Zoli B.
Hi Zoli

First, happy birth day to you :)

38 is a good age, please yourself 8-)

Regarding your question :

We have a control @...IPADDRESS / DEFINE IPADDRESS control in HMG and two samples about it.

But sadly, I haven't any experience and I'm afraid that this isn't you are searching.

In other hand, as far as I know, under normal conditions, IP address of any machine is variable; for every Internet connection will be assigned a different address to your machine. For own a fixed IP adress you need to buy it.

Probably you know all of these; all my knowledge is this.

Regards
Viva INTERNATIONAL HMG :D

User avatar
zolysoftsolutions
Posts: 101
Joined: Wed Feb 29, 2012 3:33 am
Location: Gyulakuta, Erdélyország
Contact:

Post by zolysoftsolutions » Sun Mar 31, 2013 2:55 pm

Hello Esgici,

Thank you for the wishes and for your replay.

Really this is the challenge, because the IP may vary.
But I solved at the moment in my beginner way:
- I made a PHP script. Here the IP is read and written into a text file on http
- Before I need to use the remote IP, I launch the script trough an activex control (create the file), I download the text file and I store the content of the file into a variable
- in this way my problem is solved, but I think somebody have a shorter and faster solution for this.

Best regards,
Zoli B.
_______________________________
Open eyes for you!

User avatar
mol
Posts: 2856
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 126 times
Been thanked: 65 times
Contact:

Post by mol » Sun Mar 31, 2013 7:09 pm

maybe try to catch tracert dos command and examine results this command sends to screen

jayadevu
Posts: 202
Joined: Tue May 19, 2009 7:10 am
Been thanked: 1 time

Post by jayadevu » Mon Apr 01, 2013 12:27 pm

Hi,

Pls try the following working sample:

Code: Select all

function main
   local cInternetIP := Ip_Externo()
   cInternetIP := iif("Site" $ upper(cInterNetIP),cInterNetIP,;
                      "Internet IP is:  "+cInterNetIP)
   /*
   if file("init.cld")
      REQUEST HB_GT_WIN_DEFAULT
   endif
   */
   DEFINE WINDOW Win_1 ;
      AT 0,0 ;
      WIDTH 300 ;
      HEIGHT 150 ;
      ICON INTERNETIPICON ;
      TITLE 'Internet IP Address' ;
      MAIN ;
      NOSIZE ;
      NOMAXIMIZE ;
      TOPMOST
      @ 30,25 LABEL label_1 of Win_1 VALUE cInternetIP ;
            WIDTH 250 ;
            BORDER ;
            BOLD ;
            font "Arial" SIZE 11 ;
            CENTERALIGN ;
            CLIENTEDGE ;
            TOOLTIP "Your internet IP"
      @ 80,90 BUTTON button_1 of Win_1 CAPTION "Ok " ACTION Win_1.Release ;
            TOOLTIP "Click OK to exit"
   END WINDOW
   Win_1.Center
   ACTIVATE WINDOW Win_1
return NIL



FUNCTION IP_EXTERNO()
   local url, html, vRet
   url := "http://checkip.dyndns.org/" //'http://meuip.datahouse.com.br/ automation.whatismyip.com/n09230945.asp'
   html:= ReadPage_ler( url )
   memowrit(GetMyDocumentsFolder()+"\InterNetIPInfo.html",dtoc(date())+" "+time()+" ["+html+"]")
   vRet := PegaIP_ex(html) //vRET:= html //
RETURN iif(empty(vRET),"Site Not Reachable!",vRet)

FUNCTION PegaIP_ex(cHtml)
   LOCAL Pos, PosF
   Pos := At(':', Upper(cHtml) )
   IF Pos < 1
      RETURN 0
   ENDIF
  * Pos += Len('IP?')
   cHtml := subst( cHtml, Pos+1 )
   PosF := At('<',Upper(cHtml)) - 1
   cHtml := Subst(cHtml,1,PosF)

RETURN alltrim(cHtml)

FUNCTION ReadPage_ler( cUrl )
   LOCAL oUrl, oCli, cRes := ''

   BEGIN SEQUENCE
      oUrl = TUrl():New( cUrl )
      IF EMPTY( oUrl )
         BREAK
      ENDIF
      oCli = TIpClientHttp():New( oUrl )
      IF EMPTY( oCli )
         BREAK
      ENDIF
      oCli:nConnTimeout = 20000
      IF !oCli:Open( oUrl )
         BREAK
      ENDIF
      cRes := oCli:Read()
      oCli:Close()
   END SEQUENCE
RETURN cRes

User avatar
zolysoftsolutions
Posts: 101
Joined: Wed Feb 29, 2012 3:33 am
Location: Gyulakuta, Erdélyország
Contact:

Post by zolysoftsolutions » Tue Apr 02, 2013 6:18 am

Hi jayadevu!

It works! Thank you very much.. is more simple and more proffesionist than my solution. : )

Best regards,
Zoli B.
_______________________________
Open eyes for you!

Post Reply