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