Many developers are looking to build Microsoft applications for wireless devices, and one of the keys to their success will be how well they understand the functionality and limitations of Windows CE. Here’s an introduction to Windows CE and a look at what Microsoft developers need to know to begin making the transition to wireless development.

Getting started
The Windows CE OS supports a multitude of features and can be compiled across a wide variety of CPUs. It supports a multithreaded environment and contains an optional GUI. Windows CE also follows in the Windows tradition by borrowing architecture from its desktop cousins, so any Windows programmer can easily migrate to programming for Windows CE without facing much of a learning curve.

In this article, we will look at how to develop for Windows CE for the Pocket PC and Pocket PC 2002 target platform. Both platforms are implemented using Windows CE 3.0. Microsoft has also delivered a new version of Windows CE, Windows CE.NET, which is essentially Windows CE 4.0.

The Pocket PC 2002 requires a new SDK download but is integrated with eMbedded Tools 3.0. It’s largely similar to the Pocket PC when writing applications, but it features the following enhancements:

Communications enhancements

  • New connection manager
  • Object Exchange (OBEX) support
  • Telephony and CellCore APIs

Usability enhancements

  • New notification system
  • Today screen skins
  • Smart minimize

New features in Pocket Internet Explorer
New HTML control

Developing for Windows CE on the Pocket PC platform
To develop for Windows CE 3.0, you just need to download Microsoft eMbedded Tools 3.0, which includes eMbedded Visual C++ 3.0 and eMbedded Visual Basic 3.0. It also provides all the platform SDKs you need to program for a Pocket PC device, Palm-size PC, and Handheld PC. Both Visual C++ and Visual Basic are stand-alone and do not require a copy of Visual Studio. You can download the additional SDK for Pocket PC 2002, if you want to develop applications specifically targeting the new platform.

All SDKs come with emulators that allow you to simulate the desired environment on your desktop PC. To develop for the Pocket PC or Pocket PC 2002, you don’t even need a target Pocket PC system. All you need is the eMbedded Visual Tools 3.0, all the appropriate SDKs, and a desktop PC. Figures A and B show the Pocket PC and Pocket PC 2002 emulators. If you do want to develop on a Pocket PC device, you can just hook one up to your PC using the standard ActiveSync, via USB.

Figure A
Pocket PC emulator

Figure B
Pocket PC 2002 emulator

Moving forward with eMbedded Visual Tools
Many people are surprised to find out that Microsoft’s Windows CE operating system and development tools support much of its desktop technologies. Microsoft includes support for the following projects in eMbedded Tools 3.0:

  • WCE Pocket PC 2002 Application
  • WCE Pocket PC 2002 MFC AppWizard
  • WCE Application
  • WCE ATL COM AppWizard
  • WCE Dynamic-Link Library
  • WCE MFC ActiveX ControlWizard
  • WCE MFC AppWizard (.dll)
  • WCE MFC AppWizard (.exe)
  • WCE Pocket PC Application
  • WCE Pocket PC MFC AppWizard (.exe)
  • WCE Smartphone 2002 Application
  • WCE Static Library

Microsoft supports MFC, ATL, and the regular Win32 API. The Win32 API, including MFC, is more limited than that in the desktop OS world. For example, although Windows CE allows you to do the same things as regular Windows in terms of device contexts, a lot of the duplicate behavior is not apparent in the Windows CE version.

You can paint lines, circles, and ellipses but do not have support for different mapping modes. The only mode Windows CE supports is MM_TEXT, and it doesn’t support coordinate transforms.

You might also be wondering what CPUs are supported by eMbedded Visual Tools 3.0. Although Pocket PC 2002 supports only ARM-based processor cores, eMbedded Visual Tools offers the option of selecting the following CPUs: ARM, MIPS, PPC, SHx, x86, and THUMB. Since eMbedded Tools acts as a compiler for Windows CE 3.0, it supports a wider variety of target devices, not just handheld devices.

eMbedded Visual C++ 4.0 and Windows CE.NET
Microsoft has released a new version of eMbedded Visual C++ 3.0, which is called eMbedded Visual C++ 4.0. This compiler is specifically targeted for development of the Windows CE.NET operating system. There is no eMbedded Visual Basic 4.0 as of yet. Neither is there a Pocket PC SDK for eMbedded Visual C++ 4.0, since the Pocket PC is based on the Windows CE 3.0 operating system.

For now, all you can do with Windows CE.NET is download the eMbedded Visual C++ 4.0 tool from the Microsoft Web site and develop applications with the provided emulator. You can develop for target hardware only if you spend significant amounts of money for a Windows CE.NET reference board.

One of the limitations in eMbedded Visual Tools 3.0 that I found most annoying was that eMbedded Visual C++ 3.0 does not support C++ exception handling. Consequently, eMbedded Visual C++ 3.0 could not implement the standard template library or the run-time type information. These problems have been rectified in eMbedded Visual C++ 4.0, so it’s much more compliant with the C++ standard.

Developing a real-world application
Assuming that you’re familiar with Visual Studio, you’ll quickly be able to get up and running with Windows CE and the Pocket PC. The last time I joined a startup, which was developing on the Pocket PC, it took me about five minutes to get my first “Hello World” application running on the target device itself (Figure C). Simply load eMbedded Visual C++, create a new project, choose a standard MFC Pocket PC wizard, and compile to your liking.

Figure C
Hello World application

Note that eMbedded Visual C++ includes additional options that allow you to choose a target CPU and platform. If you want to develop an application for the Pocket PC 2002 emulator, choose Pocket PC 2002 Application, Win32 (WCE x86) Debug Or Release and select Pocket PC 2002 Emulation.

If you want to compile for the real Pocket PC 2002 device, simply hook it up via ActiveSync, load eMbedded Visual C++, create the project, and set the target to Pocket PC 2002 Application, Win32 (WCE ARM) Debug Or Release, and Pocket PC 2002 (Default Device).

When creating a project, be sure to choose all the CPUs you may be targeting with your final executable. If you don’t select a needed CPU at project creation time, you will have a hard time targeting it after the project has been completed. By default, all the CPUs are selected, and this is by far the best method of development. There are no disadvantages to selecting extra CPU types.

We’ve looked at Windows CE 3.0 and Windows CE.NET, discussed Microsoft’s eMbedded Visual C++ Tools, and examined some intricacies of the Pocket PC and Pocket PC 2002. In future articles, we’ll delve a little deeper into Pocket PC programming, focusing on configuring applications to access the registry and creating a professional-looking GUI.

Going mobile

Are there other Windows CE topics you’d like us to cover? Drop us an e-mail or post a comment below.