网站首页  词典首页

请输入您要查询的函数:

 

术语 tounicode
释义 ToUnicode
语法:
int ToUnicode( UINT wVirtKey,
UINT wScanCode,
const PBYTE lpKeyState,
LPWSTR pwszBuff,
int cchBuff,
UINT wFlags
);
ToUnicode功能
该ToUnicode功能转换指定的虚拟键码和键盘状态到相应的Unicode字符或字符。
要指定一个句柄的键盘布局翻译使用指定的代码,使用ToUnicodeEx功能。
参数
wVirtKey
[in]指定虚拟键码翻译。
wScanCode
[in]指定的硬件扫描的关键代码进行翻译。的高序位这个值,如果设置的关键了。
lpKeyState
[in]指向1 256字节数组,包含当前的键盘状态。每个元素(字节数组)包含一个国家重点。如果高字节序位被设置,关键是向下。
pwszBuff
[out]指向的缓冲区,它接收翻译Unicode字符或字符。不过,此缓冲区可能会返回而不空终止即使变量顾名思义,这是空终止。
cchBuff
[in]指定的大小,宽字符的缓冲区指向的pwszBuff参数。
wFlags
[in]指定函数的行为。如果第0位被设置,菜单是活动的。通过31位1均予以保留。
返回值
该函数返回下列值之一。
- 1The指定的虚拟键是一条走不通的,关键字符(口音或读音符号)。此值是返回无论键盘布局,即使有几个字符输入,并在键盘状态中。如果可能的话,即使使用Unicode键盘布局,功能写了死键字符间距版本由pwszBuff指定的缓冲区。例如,函数写入字符间距急性(0x00B4),而不是字符NON_SPACING急性(0x0301)。
0The指定的虚拟键并没有为键盘的当前状态的翻译。这完全是由pwszBuff写入指定的缓冲区。
1One的性质是由pwszBuff写入到指定的缓冲区。
2或moreTwo或多个字符写入到由pwszBuff指定的缓冲区。这方面最常见的原因是一死,关键字符(口音或读音符号)中存储的键盘布局无法与指定的虚拟键相结合,形成一个单独的字符。然而,缓冲区可能含有返回值比指定多个字符。当发生这种情况,任何额外的字符是无效的,应该被忽略。
备注
提供给ToUnicode函数的参数可能不足以翻译的虚拟键码,因为以前死亡的关键是在键盘布局中。
通常情况下,ToUnicode执行的虚拟键代码的翻译。在某些情况下,不过,位的wScanCode参数15,可以用来区分一个按键和一个按键释放。
功能信息
最低DLL版本 user32.dll
在Winuser.h中HeaderDeclared,头文件:winuser.h
import libraryUser32.lib
最低经营systemsWindows新台币3.1
参见
键盘输入,ToAscii,ToUnicodeEx,VkKeyScan
==英文原文==ToUnicode Function
The ToUnicode function translates the specified virtual-key code and keyboard state to the corresponding Unicode character or characters.
To specify a handle to the keyboard layout to use to translate the specified code, use the ToUnicodeEx function.
Syntax
int ToUnicode( UINT wVirtKey,
UINT wScanCode,
const PBYTE lpKeyState,
LPWSTR pwszBuff,
int cchBuff,
UINT wFlags
);
Parameters
wVirtKey
[in] Specifies the virtual-key code to be translated.
wScanCode
[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.
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.
pwszBuff
[out] Pointer to the buffer that receives the translated Unicode character or characters. However, this buffer may be returned without being null-terminated even though the variable name suggests that it is null-terminated.
cchBuff
[in] Specifies the size, in wide characters, of the buffer pointed to by the pwszBuff parameter.
wFlags
[in] Specifies the behavior of the function. If bit 0 is set, a menu is active. Bits 1 through 31 are reserved.
Return Value
The function returns one of the following values.
-1The specified virtual key is a dead-key character (accent or diacritic). This value is returned regardless of the keyboard layout, even if several characters have been typed and are stored in the keyboard state. If possible, even with Unicode keyboard layouts, the function has written a spacing version of the dead-key character to the buffer specified by pwszBuff. For example, the function writes the character SPACING ACUTE (0x00B4), rather than the character NON_SPACING ACUTE (0x0301).
0The specified virtual key has no translation for the current state of the keyboard. Nothing was written to the buffer specified by pwszBuff.
1One character was written to the buffer specified by pwszBuff.
2 or moreTwo or more characters were written to the buffer specified by pwszBuff. The most common cause for this is that a dead-key character (accent or diacritic) stored in the keyboard layout could not be combined with the specified virtual key to form a single character. However, the buffer may contain more characters than the return value specifies. When this happens, any extra characters are invalid and should be ignored.
Remarks
The parameters supplied to the ToUnicode function might not be sufficient to translate the virtual-key code because a previous dead key is stored in the keyboard layout.
Typically, ToUnicode performs the translation based on the virtual-key code. In some cases, however, bit 15 of the wScanCode parameter can be used to distinguish between a key press and a key release.
Function Information
Minimum DLL Versionuser32.dll
HeaderDeclared in Winuser.h, include Windows.h
Import libraryUser32.lib
Minimum operating systemsWindows NT 3.1
See Also
Keyboard Input , ToAscii , ToUnicodeEx , VkKeyScan
==原始网址==http://msdn.microsoft.com/en-us/library/ms646320(VS.85).aspx\n
随便看

 

windows api函数参考手册包含2258条windows api函数文档,详细介绍nodejs、java、rust调用windows api的方法技巧,是学习windows api编程的入门中文文档。

 

Copyright © 2004-2023 Winrtm.com All Rights Reserved
京ICP备2021023879号-40 更新时间:2024/10/6 13:21:22