关于ToAscii function的疑问。一定给分!!!
我没有搞懂ToAscii的第二个参数uScanCode有什么用。我在调试程序时好像将uScanCode的值添错了,但是结果却没有受影响,甚至我把它添成 0 运行都很正常!!!
Why???
ToAscii 在MSDN里面的解释如下:
The ToAscii function translates the specified virtual-key code and keyboard state to the corresponding character or characters. The function translates the code using the input language and physical keyboard layout identified by the keyboard layout handle.
To specify a handle to the keyboard layout to use to translate the specified code, use the ToAsciiEx function.
int ToAscii(
UINT uVirtKey, // virtual-key code
UINT uScanCode, // scan code
CONST PBYTE lpKeyState, // key-state array
LPWORD lpChar, // buffer for translated key
UINT uFlags // active-menu option
);
Parameters
uVirtKey
[in] Specifies the virtual-key code to be translated.
uScanCode
[in] Specifies the hardware scan code of the key to be translated. The high-order bit of this value is set if the key is up (not pressed).
lpKeyState
[in] Pointer to a 256-byte array that contains the current keyboard state. Each element (byte) in the array contains the state of one key. If the high-order bit of a byte is set, the key is down (pressed).
The low bit, if set, indicates that the key is toggled on. In this function, only the toggle bit of the CAPS LOCK key is relevant. The toggle state of the NUM LOCK and SCROLL LOCK keys is ignored.
lpChar
[out] Pointer to the buffer that receives the translated character or characters.
uFlags
[in] Specifies whether a menu is active. This parameter must be 1 if a menu is active, or 0 otherwise.