HOW TO: Find the IP Address of a CE Device Connected Through RAS to a Windows NT Server (301089)



The information in this article applies to:

  • Microsoft Windows CE 3.0 Professional Edition for the Handheld PC
  • Microsoft Windows CE 3.0 for the Handheld PC
  • Microsoft Windows CE 2.12 for the Handheld PC
  • Microsoft Windows CE 2.11 for the Handheld PC
  • Microsoft Windows CE 2.0 for the Handheld PC
  • Microsoft Windows CE Operating System, Versions 2.12
  • Microsoft Windows CE Operating System, Versions 2.11
  • Microsoft Windows CE for the Pocket PC

This article was previously published under Q301089

SUMMARY

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.

back to the top

Requirements

The following items describe the recommended hardware, software, network infrastructure, skills and knowledge, and service packs you will need:
  • Microsoft Windows CE Operating System versions 2.11, 2.12

    -or-
  • Microsoft Windows CE for the Pocket PC

    -or
  • Microsoft Windows CE versions 2.11, 2.12, 3.0, 3.0 Professional Edition for the Handheld PC

    -or-
  • Microsoft Windows CE versions 2.11, 2.12 for the Palm-size PC
back to the top

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:
  1. Call RasEnumConnections(). This gives you the number of active point-to-point protocol (PPP) connections. You can stop here if this number is zero.
  2. 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.
  3. 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.
  4. 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).
  5. 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.
  6. 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.
  7. IP addresses that remain after you eliminate the Ethernet adapters must be PPP addresses.
back to the top

REFERENCES

This article is relevant for Pocket PC and earlier versions of Windows CE. Microsoft Windows CE Platform Builder (PB) 3.0 contains a new API that makes this easier.

back to the top

Modification Type:MajorLast Reviewed:12/1/2003
Keywords:kbhowto kbHOWTOmaster KB301089 kbAudDeveloper