Skip to content

Determining IP Address of a Windows Mobile device

Oct 05, 2009 | 42Gears Team

Code to determine IP addresses of adapters on a Windows Mobile device, using IPHelper APIs.

Add Iphlpapi.lib to linker settings.

#include “Iphlpapi.h”

PIP_ADAPTER_INFO pinfo = NULL;
ULONG OutBufLen = 0;
DWORD dwRet = GetAdaptersInfo(NULL, &OutBufLen);
if (dwRet == ERROR_BUFFER_OVERFLOW)
{
pinfo = (PIP_ADAPTER_INFO)malloc(OutBufLen);
dwRet = GetAdaptersInfo(pinfo,&OutBufLen);
while (pinfo != NULL)
{
if (dwRet==ERROR_SUCCESS)
{
PIP_ADDR_STRING pAddressList = &(pinfo->IpAddressList);
do
{
printf(pAddressList->IpAddress.String);
pAddressList = pAddressList->Next;
} while (pAddressList != NULL);
}
pinfo = pinfo->Next;
}
free(pinfo);
}

Subscribe for our free newsletter

Thank you! you are successfully subscribed.
newsletter

Exclusive News and Updates on Enterprise Mobility!

* I consent to receive newsletters via email from 42Gears and its Affiliates.
Please agree
* I have reviewed and agreed to 42Gears Privacy Policy and Terms of Use prior to subscribing and understand that I may change my preference or unsubscribe at any time.
Please agree
Please verify captcha
Please enter a valid official email