Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.clipper.visual-objects > #5159 > unrolled thread

IP Address function

Started byMartin <spam@spam.spam>
First post2013-04-26 16:28 +0100
Last post2013-04-29 11:09 -0400
Articles 6 — 5 participants

Back to article view | Back to comp.lang.clipper.visual-objects


Contents

  IP Address function Martin <spam@spam.spam> - 2013-04-26 16:28 +0100
    Re: IP Address function Massimo Bighelli <info@arcasistemi.it> - 2013-04-26 18:07 +0200
      Re: IP Address function Martin <spam@spam.spam> - 2013-04-30 15:15 +0100
    Re: IP Address function dlzc <dlzc1@cox.net> - 2013-04-26 12:12 -0700
    Re: IP Address function "Willie Moore" <williem@wmconsulting.com> - 2013-04-26 14:23 -0500
    Re: IP Address function "Jamal" <jamal@examples.net> - 2013-04-29 11:09 -0400

#5159 — IP Address function

FromMartin <spam@spam.spam>
Date2013-04-26 16:28 +0100
SubjectIP Address function
Message-ID<_1xet.160753$ui1.20601@fx02.fr7>
I am trying to find my PCs IP address from within VO, I found this in 
our code and I am trying to test it.

My address is 192.168.2.232 this returns 16.243.24.0

The second debug through a converter gives me 232.2.168.192

Any ideas what is wrong please?

Thanks

Martin

FUNC GetIPAddress1(cHost AS STRING) AS STRING PASCAL
     //  Takes a address string and returns IP string
     LOCAL cRet      AS STRING
     LOCAL pHostEnt  as _WInHostEnt
     LOCAL Tmp1 as DWORD // VO 2.8 PHIL
     LOCAL Tmp2 as DWORD
     LOCAL Tmp3 as _winin_addr
     LOCAL Tmp4 as psz


	IF SLen(cHost) > 0
		pHostEnt := gethostbyname(String2Psz(cHost))

		IF pHostEnt != null_ptr
			// VO 2.8 PHIL - changed data types
			Tmp1 := DWORD(pHostEnt.h_addr_list)
hit_key(str(tmp1))
         	Tmp2 := DWORD(ptr(_cast, Tmp1))
hit_key(str(tmp2))
         	Tmp3 := @Tmp2
         	Tmp4 := inet_ntoa(Tmp3)		
        	
			cRet := Psz2String(Tmp4)
		ENDIF
	ENDIF

RETURN cRet

[toc] | [next] | [standalone]


#5160

FromMassimo Bighelli <info@arcasistemi.it>
Date2013-04-26 18:07 +0200
Message-ID<kle8o8$amp$1@speranza.aioe.org>
In reply to#5159
Martin,

this is my code:

sHost := AllTrim(HostName())
SELF:oDCwIP:value := GetIPAddress(sHost)

Massimo


Il 26/04/2013 17:28, Martin ha scritto:
> I am trying to find my PCs IP address from within VO, I found this in
> our code and I am trying to test it.
>
> My address is 192.168.2.232 this returns 16.243.24.0
>
> The second debug through a converter gives me 232.2.168.192
>
> Any ideas what is wrong please?
>
> Thanks
>
> Martin
>
> FUNC GetIPAddress1(cHost AS STRING) AS STRING PASCAL
>      //  Takes a address string and returns IP string
>      LOCAL cRet      AS STRING
>      LOCAL pHostEnt  as _WInHostEnt
>      LOCAL Tmp1 as DWORD // VO 2.8 PHIL
>      LOCAL Tmp2 as DWORD
>      LOCAL Tmp3 as _winin_addr
>      LOCAL Tmp4 as psz
>
>
>      IF SLen(cHost) > 0
>          pHostEnt := gethostbyname(String2Psz(cHost))
>
>          IF pHostEnt != null_ptr
>              // VO 2.8 PHIL - changed data types
>              Tmp1 := DWORD(pHostEnt.h_addr_list)
> hit_key(str(tmp1))
>              Tmp2 := DWORD(ptr(_cast, Tmp1))
> hit_key(str(tmp2))
>              Tmp3 := @Tmp2
>              Tmp4 := inet_ntoa(Tmp3)
>
>              cRet := Psz2String(Tmp4)
>          ENDIF
>      ENDIF
>
> RETURN cRet


*Massimo Bighelli* ARCA Sistemi S.r.l.

[toc] | [prev] | [next] | [standalone]


#5183

FromMartin <spam@spam.spam>
Date2013-04-30 15:15 +0100
Message-ID<YlQft.224218$ui1.3544@fx02.fr7>
In reply to#5160
Thanks all, I should have left the original programmers name in - he 
broke it when converting from a sample.

It seems to work fine now thankyou

tested on XP and W7

On 26/04/2013 17:07, Massimo Bighelli wrote:
> Martin,
>
> this is my code:
>
> sHost := AllTrim(HostName())
> SELF:oDCwIP:value := GetIPAddress(sHost)
>
> Massimo
>
>
> Il 26/04/2013 17:28, Martin ha scritto:
>> I am trying to find my PCs IP address from within VO, I found this in
>> our code and I am trying to test it.
>>
>> My address is 192.168.2.232 this returns 16.243.24.0
>>
>> The second debug through a converter gives me 232.2.168.192
>>
>> Any ideas what is wrong please?
>>
>> Thanks
>>
>> Martin
>>
>> FUNC GetIPAddress1(cHost AS STRING) AS STRING PASCAL
>>      //  Takes a address string and returns IP string
>>      LOCAL cRet      AS STRING
>>      LOCAL pHostEnt  as _WInHostEnt
>>      LOCAL Tmp1 as DWORD // VO 2.8 PHIL
>>      LOCAL Tmp2 as DWORD
>>      LOCAL Tmp3 as _winin_addr
>>      LOCAL Tmp4 as psz
>>
>>
>>      IF SLen(cHost) > 0
>>          pHostEnt := gethostbyname(String2Psz(cHost))
>>
>>          IF pHostEnt != null_ptr
>>              // VO 2.8 PHIL - changed data types
>>              Tmp1 := DWORD(pHostEnt.h_addr_list)
>> hit_key(str(tmp1))
>>              Tmp2 := DWORD(ptr(_cast, Tmp1))
>> hit_key(str(tmp2))
>>              Tmp3 := @Tmp2
>>              Tmp4 := inet_ntoa(Tmp3)
>>
>>              cRet := Psz2String(Tmp4)
>>          ENDIF
>>      ENDIF
>>
>> RETURN cRet
>
>
> *Massimo Bighelli* ARCA Sistemi S.r.l.

[toc] | [prev] | [next] | [standalone]


#5162

Fromdlzc <dlzc1@cox.net>
Date2013-04-26 12:12 -0700
Message-ID<450b546d-52bc-4c36-bd84-89baed372678@googlegroups.com>
In reply to#5159
Dear Martin:

On Friday, April 26, 2013 8:28:09 AM UTC-7, Martin wrote:
...
> I am trying to find my PCs IP address from within
> VO,

This is stored in the registry, if all else fails.

> I found this in our code and I am trying to test it.
>
> My address is 192.168.2.232 this returns 16.243.24.0
> 
> The second debug through a converter gives me
> 232.2.168.192

Which is correct, except byte reversed.  So it looks like an "endian" problem.

Your IP address is a 32-it integer, or 4 8-bit bytes, or 4 single byte characters.

I would:
- Shell execute "IPCONFIG /all >this.txt"
- parse the text file this.txt
... lots easier to dual-platform on Linux this way

David A. Smith

[toc] | [prev] | [next] | [standalone]


#5163

From"Willie Moore" <williem@wmconsulting.com>
Date2013-04-26 14:23 -0500
Message-ID<klek7c$ct0$1@speranza.aioe.org>
In reply to#5159
Martin,

I would go with the code that Massimo posted. If you want a sample, look at 
the NBTStat sample. It will not only give you the IP address on your 
computer but show you how you can send a packet over the network to query 
another computer. It is the same as doing a NBTStat -a from and cmd prompt.

Regards,
Willie
Vulcan VIP

"Martin"  wrote in message news:_1xet.160753$ui1.20601@fx02.fr7...

I am trying to find my PCs IP address from within VO, I found this in
our code and I am trying to test it.

My address is 192.168.2.232 this returns 16.243.24.0

The second debug through a converter gives me 232.2.168.192

Any ideas what is wrong please?

Thanks

Martin

FUNC GetIPAddress1(cHost AS STRING) AS STRING PASCAL
     //  Takes a address string and returns IP string
     LOCAL cRet      AS STRING
     LOCAL pHostEnt  as _WInHostEnt
     LOCAL Tmp1 as DWORD // VO 2.8 PHIL
     LOCAL Tmp2 as DWORD
     LOCAL Tmp3 as _winin_addr
     LOCAL Tmp4 as psz


IF SLen(cHost) > 0
pHostEnt := gethostbyname(String2Psz(cHost))

IF pHostEnt != null_ptr
// VO 2.8 PHIL - changed data types
Tmp1 := DWORD(pHostEnt.h_addr_list)
hit_key(str(tmp1))
         Tmp2 := DWORD(ptr(_cast, Tmp1))
hit_key(str(tmp2))
         Tmp3 := @Tmp2
         Tmp4 := inet_ntoa(Tmp3)

cRet := Psz2String(Tmp4)
ENDIF
ENDIF

RETURN cRet 

[toc] | [prev] | [next] | [standalone]


#5172

From"Jamal" <jamal@examples.net>
Date2013-04-29 11:09 -0400
Message-ID<klm2eu$fpc$1@speranza.aioe.org>
In reply to#5159
See:

https://groups.google.com/forum/?fromgroups#!searchin/comp.lang.clipper.visual-objects/get$20IP/comp.lang.clipper.visual-objects/5S1PCH-kMdY/1VJvn7jlJToJ

Jamal

"Martin"  wrote in message news:_1xet.160753$ui1.20601@fx02.fr7...

I am trying to find my PCs IP address from within VO, I found this in
our code and I am trying to test it.

My address is 192.168.2.232 this returns 16.243.24.0

The second debug through a converter gives me 232.2.168.192

Any ideas what is wrong please?

Thanks

Martin

FUNC GetIPAddress1(cHost AS STRING) AS STRING PASCAL
     //  Takes a address string and returns IP string
     LOCAL cRet      AS STRING
     LOCAL pHostEnt  as _WInHostEnt
     LOCAL Tmp1 as DWORD // VO 2.8 PHIL
     LOCAL Tmp2 as DWORD
     LOCAL Tmp3 as _winin_addr
     LOCAL Tmp4 as psz


IF SLen(cHost) > 0
pHostEnt := gethostbyname(String2Psz(cHost))

IF pHostEnt != null_ptr
// VO 2.8 PHIL - changed data types
Tmp1 := DWORD(pHostEnt.h_addr_list)
hit_key(str(tmp1))
         Tmp2 := DWORD(ptr(_cast, Tmp1))
hit_key(str(tmp2))
         Tmp3 := @Tmp2
         Tmp4 := inet_ntoa(Tmp3)

cRet := Psz2String(Tmp4)
ENDIF
ENDIF

RETURN cRet 

[toc] | [prev] | [standalone]


Back to top | Article view | comp.lang.clipper.visual-objects


csiph-web