Registrations are now open. Join us today!
There is still a lot of work to do on the wiki yet! More information about editing can be found here.
Already have an account?

Microsoft KB Archive/100486

From BetaArchive Wiki

PRB: AttachThreadInput() Resets Keyboard State

PSS ID Number: Q100486 Article last modified on 11-29-1994

3.10

WINDOWS NT

The information in this article applies to:
- Microsoft Win32 Software Development Kit (SDK) for Windows NT, version 3.1

SYMPTOMS

Start with a program that calls AttachThreadInput() to a thread in another process. Call GetKeyboardState() to get the current key. Call SetKeyboardState() to set the keystate. This call returns TRUE, indicating success, but the keystate is not successfully set.

If the thread is in the same process, calling SetKeyboardState() works as expected.

CAUSE

When attaching to another thread, a temporary message queue is created. This queue contains a copy of the keystate information from the queue to which you are attaching. When the keystate is set, the temporary queue keystate is updated and the application programming interface (API) succeeds. However, when the detach occurs, the keystate change information is lost and reverts to what it was before the attach.

RESOLUTION

To work around the problem, either:

  • Stay attached

    -or-

  • Use hooks

STATUS

This problem will not be resolved in the release of Windows NT version 3.1; however, a resolution is being considered for a future release.

Additional reference words: 3.10 KBCategory: kbprg kbprb KBSubcategory: UsrMisc

=================================================================

Copyright Microsoft Corporation 1994.