This article describes a programmatic method for finding the IP address of a Microsoft Windows CE device that is connected through Remote Access Service (RAS) to a Microsoft Windows NT Server in Windows CE versions 2.11 and 2.12. IP addresses are typically assigned by a Dynamic Host Configuration Protocol (DHCP) server.
Finding the IP Address of a CE Device Connected Through RAS to a Windows NT Server
Unlike Windows CE version 3.0, versions 2.11 and 2.12 do not support the RasGetProjectionInfo() API. This API is also not available in Pocket PC devices.
In essence, by a process of elimination you can programmatically find out the IP address that is assigned to your Windows CE device by the RAS server. The process is somewhat complicated, but you may not have to go beyond step 2 below.
To find the IP address assigned to your Windows CE device by a RAS server:
Call RasEnumConnections(). This gives you the number of active point-to-point protocol (PPP) connections. You can stop here if this number is zero.
Call gethostname(szHost); pHostEnt = gethostbyname(szHost). This gives you a list of IP addresses that are active on the local device. (If it only returns the loopback address, there are no active adapters.) You can stop here if you do not need to know whether the IP addresses are Ethernet PPP IP addresses. If the number of IP addresses returned matches the number of PPP connections from step 1, you are done.
Enumerate through the keys under HLM\Comm in the registry. Check for the "Group"="NDIS" value. This lists all of the network driver interface specification (NDIS) miniports and miniport instances.
For each NDIS miniport, look for the registry subkey Parms\TcpIp. If this subkey exists, it is a miniport instance (in other words, NE20001 rather than NE2000).
For each miniport instance, look at the value "IpAddress", which is the statically assigned IP address for the adapter. Any match to the list that is returned from gethostbyname() is an Ethernet adapter.
For each miniport instance, look at the value "DHCPIpAddress", which is the dynamically assigned IP address for the adapter. Any match to the list that is returned from gethostbyname() is an Ethernet adapter.
IP addresses that remain after you eliminate the Ethernet adapters must be PPP addresses.