Share via


Overview of 32-Bit Programming

The 32-bit API was designed to minimize the impact on existing code so that 16-bit applications could be adapted as easily as possible. However, some changes were mandated by the larger address space. Pointers are all 32 bits wide and no longer near or far, and your code cannot make assumptions based on segmented memory.

Items which have increased to 32 bits include:

  • Window handles

  • Handles to other objects, such as pens, brushes, and menus

  • Graphics coordinates

These size differences are generally resolved in WINDOWS.H or by the C language, but some changes to source code are necessary. Because the different sizes can change the way information is packed in some message parameters, you must rewrite code that handles these messages. The larger size of graphics coordinates also affects a number of function calls.

Some source code changes are required because Win32 uses higher-level mechanisms for certain operations, such as MS-DOS calls. With these mechanisms, the 32-bit API is adaptable to many platforms, and it supports powerful new features such as multiple threads of execution.

Although Windows 3.x and Win32 were designed to be as compatible as possible, you may need to carefully review large amounts of source code. Where do you start? The top-down approach is recommended:

  1. Compile the application for 32 bits, and note the compiler-generated errors.

  2. Replace complex procedures that are difficult to port, and procedures written in assembly language, with stub procedures (which do nothing except return).

  3. Fix errors in the main portion of the application, using the techniques described in this chapter.

  4. Individually fill each stub procedure with portable code after the main portion of the application compiles and runs correctly.