Microsoft KB Archive/94917

{|
 * width="100%"|

INFO: Uniqueness Values in User and GDI Handles

 * }

Q94917

-

The information in this article applies to:


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

-

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.

Additional query words:

Keywords : kbGDI kbOSWinNT kbOSWin2000 kbSDKWin32 kbGrpDSUser

Issue type : kbinfo

Technology : kbAudDeveloper kbWin32sSearch kbWin32API