The SetKeyboardState function copies a 256-byte array of keyboard key states into the calling thread's keyboard input-state table. This is the same table accessed by the GetKeyboardState and GetKeyState functions. Changes made to this table do not affect keyboard input to any other thread.
Syntax
BOOL SetKeyboardState(
LPBYTE lpKeyState );
Parameters
lpKeyState
- [in] Pointer to a 256-byte array that contains keyboard key states.
Return Value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero. To get extended error information, call GetLastError.
Remarks
Because the SetKeyboardState function alters the input state of the calling thread and not the global input state of the system, an application cannot use SetKeyboardState to set the NUM LOCK, CAPS LOCK, or SCROLL LOCK (or the Japanese KANA) indicator lights on the keyboard. These can be set or cleared using SendInput to simulate keystrokes.
Windows NT/2000/XP: The keybd_event function can also toggle the NUM LOCK, CAPS LOCK, and SCROLL LOCK keys.
Windows 95/98/Me: The keybd_event function can toggle only the CAPS LOCK and SCROLL LOCK keys. It cannot toggle the NUM LOCK key.
本文详细介绍了SetKeyboardState函数的功能及用法。该函数能够将256字节的键盘状态数组复制到调用线程的键盘输入状态表中,但不会影响其他线程的键盘输入。文章还讨论了如何通过其他手段控制键盘指示灯。
249

被折叠的 条评论
为什么被折叠?



