INFO: Uniqueness Values in User and GDI Handles (94917)



The information in this article applies to:

  • Microsoft Win32 Application Programming Interface (API), when used with:
    • the operating system: Microsoft Windows NT 3.1
    • the operating system: Microsoft Windows NT 3.5

This article was previously published under Q94917

SUMMARY

Windows NT versions prior to Windows NT 4.0 divide the User and GDI handles into the following two parts:
  • The lower 16-bits is an index into a system table of handle structures, which includes information such as the type of handle (window, menu, cursor, and so forth), as well as a value called the uniqueness.
  • The upper 16-bits contain the same uniqueness value.

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.

Modification Type:MinorLast Reviewed:8/2/2004
Keywords:kbGDI kbinfo KB94917