在VB.NET中:
ChrW(70)
Run Code Online (Sandbox Code Playgroud)
在C#中你可以施放:
(char) 70
Run Code Online (Sandbox Code Playgroud)
小智 6
我使用user32.dll的库类解决了这个问题.我更喜欢Framework类,但找不到一个,所以这对我有用.
Imports System.Runtime.InteropServices
Public Class KeyCodeToAscii
<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) _
As Char
Dim lpKeyState As Byte() = New Byte(255) {}
GetKeyboardState(lpKeyState)
Dim lpChar As Byte() = New Byte(1) {}
If ToAscii(uVirtKey, 0, lpKeyState, lpChar, 0) = 1 Then
Return Convert.ToChar((lpChar(0)))
Else
Return New Char()
End If
End Function
End Class
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
37449 次 |
| 最近记录: |