User32ToUnicodeEx Method
Translates the specified virtual-key code and keyboard state to the corresponding Unicode character or characters.
Namespace: DevCase.Win32.NativeMethodsAssembly: DevCase.net48 (in DevCase.net48.dll) Version: 6.0.0.0 (6.0)
XMLNS for XAML: Not mapped to an xmlns.
[DllImportAttribute("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)]
public static int ToUnicodeEx(
uint wVirtKey,
uint wScanCode,
byte[] lpKeyState,
StringBuilder pwszBuff,
int cchBuff,
uint wFlags,
IntPtr dwhkl
)
<DllImportAttribute("User32.dll", CharSet := CharSet.Auto, ExactSpelling := true>]
Public Shared Function ToUnicodeEx (
wVirtKey As UInteger,
wScanCode As UInteger,
lpKeyState As Byte(),
<OutAttribute> pwszBuff As StringBuilder,
cchBuff As Integer,
wFlags As UInteger,
dwhkl As IntPtr
) As Integer
Dim wVirtKey As UInteger
Dim wScanCode As UInteger
Dim lpKeyState As Byte()
Dim pwszBuff As StringBuilder
Dim cchBuff As Integer
Dim wFlags As UInteger
Dim dwhkl As IntPtr
Dim returnValue As Integer
returnValue = User32.ToUnicodeEx(wVirtKey,
wScanCode, lpKeyState, pwszBuff,
cchBuff, wFlags, dwhkl)
public:
[DllImportAttribute(L"User32.dll", CharSet = CharSet::Auto, ExactSpelling = true)]
static int ToUnicodeEx(
unsigned int wVirtKey,
unsigned int wScanCode,
array<unsigned char>^ lpKeyState,
[OutAttribute] StringBuilder^ pwszBuff,
int cchBuff,
unsigned int wFlags,
IntPtr dwhkl
)
[<DllImportAttribute("User32.dll", CharSet = CharSet.Auto, ExactSpelling = true)>]
static member ToUnicodeEx :
wVirtKey : uint32 *
wScanCode : uint32 *
lpKeyState : byte[] *
pwszBuff : StringBuilder byref *
cchBuff : int *
wFlags : uint32 *
dwhkl : IntPtr -> int
No code example is currently available or this language may not be supported.
- wVirtKey UInt32
-
The virtual-key code to be translated.
See Virtual-Key Codes:
https://msdn.microsoft.com/en-us/library/windows/desktop/dd375731%28v=vs.85%29.aspx
- wScanCode UInt32
-
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 Byte
-
A 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 StringBuilder
-
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 Int32
-
The size, in characters, of the buffer pointed to by the pwszBuff parameter.
- wFlags UInt32
-
The behavior of the function.
If bit 0 is set, a menu is active.
Bits 1 through 31 are reserved.
- dwhkl IntPtr
-
The input locale identifier used to translate the specified code.
This parameter can be any input locale identifier previously returned by the LoadKeyboardLayout function.
Int32
The function returns one of the following values.
-1:
The 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).
0:
The specified virtual key has no translation for the current state of the keyboard.
Nothing was written to the buffer specified by
pwszBuff.
1:
One character was written to the buffer specified by
pwszBuff.
2 ≤:
Two 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.