Using STRICT Type Checking
To get the most benefit from STRICT type checking, there are additional guidelines you should follow. Your code will be more portable in future versions of Windows if you make the following changes:
Change | To |
HANDLE | A specific handle such as HINSTANCE, HMODULE, HGLOBAL, HLOCAL, and so on |
WORD | UINT, except where you want a 16-bit value even when the platform is 32 bits |
WORD | WPARAM, where wParam is declared |
LONG | LPARAM or LRESULT as appropriate |
Whenever you need an integer data type, you should declare it as UINT except where a 16-bit value is specifically required (as in a structure or parameter). Even if a variable never exceeds the range of a 16-bit integer, it can be handled by the processor more efficiently if it is 32 bits.
The types WPARAM, LPARAM, LRESULT, and void * are “polymorphic data types.” They hold different kinds of data at different times, even when STRICT type checking is enabled. To get the benefit of type checking, you should cast values of these types as soon as possible. Note that message crackers (as well as the Microsoft Foundation classes) automatically recast wParam and lParam for you in a portable way.
Take special care to distinguish HMODULE and HINSTANCE types. Even with STRICT enabled, they are defined as the same base type. Most kernel module management functions use HINSTANCE types, but there are a few API functions that return or accept only HMODULE types.