I am developing an app on a Windows Mobile 2003 SE with built in
Wireless B. I need to find a way to get the IP address of the device
on the wireless network programmatically. Any help is much
appreciated.

Re: Wireless DHCP Address by Brian

Brian
Wed May 24 09:57:09 CDT 2006

cbrown@duclaw.com wrote in news:1148481182.710774.97990
@u72g2000cwu.googlegroups.com:

> I am developing an app on a Windows Mobile 2003 SE with built in
> Wireless B. I need to find a way to get the IP address of the device
> on the wireless network programmatically. Any help is much
> appreciated.
>
>

You want to use the gethostname and gethostbyname functions (I'm assuming
your language/environment is EVC++):

HOSTENT *lpHostEnt;
char szHostName[256];

gethostname(szHostName, sizeof(szHostName));
lpHostEnt = gethostbyname(szHostName);



Your IP addresses are in lpHostEnt->h_addr_list, which is an array of
in_addr structures.

lpHostEnt->h_addr_list[0].S_un.S_un_b.b1 is the first byte of the first
address, lpHostEnt->h_addr_list[0].S_un.S_un_b.b2 is the second byte of the
first address, etc.

Regards,
Brian

Re: Wireless DHCP Address by cbrown

cbrown
Wed May 24 10:16:47 CDT 2006

Thanks for the info Brian.

I also used VB.NEt to access the IP using the following code.

Dim sHostName As String
Dim i As Integer
sHostName = System.Net.Dns.GetHostName()
Dim ipE As System.Net.IPHostEntry =
System.Net.Dns.GetHostByName(sHostName)
Dim ipA() As System.Net.IPAddress = ipE.AddressList
For i = 0 To ipA.GetUpperBound(0)
lblInfo.Text = "ip (" & i & ") : " & ipA(i).ToString
Next