API Considerations

When porting code from one platform to another, an important consideration is the difference in the APIs supported by the two operating systems. As stated earlier, Windows CE does not support any 16-bit functions and some Win32 functions are not implemented completely, for example, a full range of styles or flags. Also be aware that Windows CE supports and extends an essential subset of the Win32 API, while excluding functions that are not needed, or are redundant, for Windows CE-based devices. For example, the Windows CE graphical device interface provides a powerful, full-color graphical display system by supporting many of the shape, bit-block transfer, palette, font, and color functions. However, to remain compact, some of the Win32 special graphic functions, such as MoveTo and LineTo, are eliminated.

In addition to supporting much of the Win32 API, Windows CE extends it in a number of ways. Most of these extensions support the unique capabilities of Windows CE-based platforms. Some, such as the command bar API, replace a set of Win32 functions and work in a way that is more suitable for Windows CE-based devices.

When you port an application from Win32 to Windows CE, remove unsupported functions and modify your code to use supported functions. Then, thoroughly review your code, keeping in mind the limitations and potentials of your platform. For more information, see Example Program for H/PC.

You can reuse any Visual C++, Visual Basic, or Visual J++ code in your Windows CE-based application. If your application was developed using a Microsoft IDE, such as Visual C++, Visual Basic, or Visual J++, you can continue to use that IDE with Windows CE by installing the appropriate toolkit.

As discussed earlier, many Win32 applications are developed using MFC and ATL. Windows CE supports subsets of both of these tools. In addition, Windows CE supports a subset of COM/OLE, a powerful and flexible approach to object-oriented programming that is used by many applications. You may be able to port an application that uses COM/OLE, MFC, or ATL with only minor revisions.