Type a page name and press Enter. You'll jump to the page if it exists, or you can create it if it doesn't.
To create a page in a module other than user32, prefix the name with the module name and a period.
<DllImport("user32")> _
Public Function ToAscii( _
ByVal uVirtKey As Integer, _
ByVal uScanCode As Integer, _
ByVal lpKeyState() As Byte, _
ByVal lpChar As StringBuilder, _
ByVal uFlags As Integer)
End Function
'or..
Public Declare Function ToAscii Lib "user32" (ByVal uVirtKey As Win32CONST.KeyEvent, ByVal uScanCode As Integer, ByVal lpKeyState() As Byte, ByRef lpChar As Integer, ByVal uFlags As Win32CONST.ToAsciiFlags) As Integer
User-Defined Types:
Public Enum ToAsciiFlags As Integer
MENU_IS_ACTIVE = 1
MENU_IS_INACTIVE = 0
End Enum
Notes:
None.
Tips & Tricks:
Please add some!
Sample Code:
<DllImport("User32.dll")> _
Public Shared Function ToAscii(ByVal uVirtKey As Integer, ByVal uScanCode As Integer, ByVal lpbKeyState As Byte(), ByVal lpChar As Byte(), ByVal uFlags As Integer) As Integer
End Function
<DllImport("User32.dll")> _
Public Shared Function GetKeyboardState(ByVal pbKeyState As Byte()) As Integer
End Function
Public Shared Function GetAsciiCharacter(ByVal uVirtKey As Integer, ByVal uScanCode As Integer) As Char
Dim lpKeyState As Byte() = New Byte(255) {}
GetKeyboardState(lpKeyState)
Dim lpChar As Byte() = New Byte(1) {}
If ToAscii(uVirtKey, uScanCode, lpKeyState, lpChar, 0) = 1 Then
Return Chr(lpChar(0))
Else
Return New Char()
End If
End Function
Alternative Managed API:
Do you know one? Please contribute it!
The ToAsciiEx API
2/18/2010 3:53:19 AM - -115.70.199.66
Please edit this page!
Do you have...
helpful tips or sample code to share for using this API in managed code?
corrections to the existing content?
variations of the signature you want to share?
additional languages you want to include?
Select "Edit This Page" on the right hand toolbar and edit it! Or add new pages containing supporting types needed for this API (structures, delegates, and more).