Microsoft KB Archive/291100

From BetaArchive Wiki

HOW TO: Find the IP Address of a CE Device Connected via RAS to a Windows NT Server

Q291100



The information in this article applies to:


  • Microsoft Windows CE Operating System versions 2.11, 2.12
  • Microsoft Windows CE for the Pocket PC
  • Microsoft Windows CE versions 2.11, 2.12, 3.0, 3.0 Professional Edition for the Handheld PC
  • Microsoft Windows CE versions 2.11, 2.12 for the Palm-size PC





SUMMARY

This article describes a programmatic method for finding the IP address of a Windows CE device that is connected via Remote Access Service (RAS) to a Windows NT Server in Windows CE versions 2.11 and 2.12. The IP address is typically assigned by a Dynamic Host Configuration Protocol (DHCP) server.



[GRAPHIC: Step 1]The Platform Builder API

In Platform Builder (PB) 3.0, a new API exists that makes this easier. For Pocket PC and earlier versions of Windows CE, this process is a bit more complicated. 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.


[GRAPHIC: Step 2]Find IP Address of CE Device

In essence, by process of elimination you can programmatically find out the IP address 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.

  1. Call RasEnumConnections(). This will give 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 will give you a list of IP addresses that are active on the local device. (If it only returns the loopback address, then there are no active adapters.) You can stop here if you do not care 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, then you are done.
  3. Enumerate through the keys under HLM\Comm in the registry. Check for the value "Group"="NDIS". This will give you 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, then 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. For any that match the list returned from gethostbyname() you would then know it is an Ethernet adapter.
  6. For each miniport instance, look at the value "DHCPIpAddress", which is the dynamically assigned IP address for the adapter. For any that match the list returned from gethostbyname(), you would know that it is an Ethernet adapter.

After eliminating the Ethernet adapters the remaining IP addresses must be PPP addresses.

Additional query words:

Keywords : _IK kbGraphxLink kbAudDeveloper kbHOWTOmaster
Issue type : kbhowto
Technology : kbOSWinCE kbPocketSearch kbWinCESearch kbWinCE211HPC kbWinCE212HPC kbWinCE300HPC kbWinCEPro300HPC kbWinCE211PalmsizePC kbWinCE212PalmsizePC kbWinCE211 kbWinCE212 kbWinCEPocketPC


Last Reviewed: June 15, 2001
© 2001 Microsoft Corporation. All rights reserved. Terms of Use.