PC IP Address

Post Reply
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

PC IP Address

Post by Jeff Barnes »

Hi Everybody,

I'm trying to have my program store the end users internal IP Address but I can not seem to get the actual address.

I am using:

GetHostByName( GetHostName() )

But it always returns 0.0.0.0

What am I doing wrong?

Thanks,
Jeff
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Post by James Bott »

Jeff,

You must add WsaStartup() before the call to Gethostbyname() and add a WsaCleanup() after the call.

Try this:

Function GetIP()
Local cVar1
WsaStartUp()
cVar1 := GetHostByName( GetHostName() )
WsaCleanUp()
return cVar1

James
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Post by Jeff Barnes »

Thanks James.

Works perfectly.


Jeff
Post Reply