INFO: Uniqueness Values in User and GDI Handles

ID: Q94917

The information in this article applies to:

SUMMARY

Windows NT versions prior to Windows NT 4.0 divide the User and GDI handles into the following two parts:

MORE INFORMATION

The first time a handle is issued by the system, the uniqueness value is 0 (zero). It is incremented each time the handle is re-used. In Windows NT 3.1, if you pass in a value of 0xFFFF for the uniqueness, the client side (that is, User32.dll) will look up the correct uniqueness value in shared memory and use the correct handle. In Windows NT 3.5, use 0x0000 for the uniqueness value.

This is important because it alleviates potential conflicts with re-used handles. For example, when a window is destroyed, its handle is reused by the system. The uniqueness value prevents an old handle to a destroyed window from being misinterpreted by the system as the handle to a new object, which was given the same handle value.

Windows NT 4.0 no longer uses uniqueness values. All User and GDI handles are unique 32-bit values where the entire value is an index into the system table of handle structures. In the case of 16-bit applications, the Windows On Windows (WOW) subsystem automatically converts the 16-bit handles to 32- bit values and back again.

In Win32s, use 0x0000 in the upper 16 bits for the uniqueness.

Additional query words:

Keywords          : kbGDI kbNTOS310 kbNTOS350 kbNTOS351 kbGrpUser 
Issue type        : kbinfo

Last Reviewed: December 12, 1998