[转载]获取键盘信息
代码:Option Explicit
Private Declare Function GetCaretBlinkTime Lib "user32" () As Long
Private Declare Function SystemParametersInfo& Lib "user32" Alias "SystemParametersInfoA" (ByVal uAction As Long, ByVal uParam As Long, lpvParam As Any, ByVal fuWinIni As Long)
Private Declare Function GetKeyboardType Lib "user32" (ByVal nTypeFlag As Long) As Long
Private Const spi_getkeyboardspeed = 10
Private Const spi_getkeyboarddelay = 22
Private Sub Command1_Click()
End
End Sub
Private Sub Form_Load()
Dim ktype As String
Dim r As Long
Dim q As Long
Dim k As Long
k = GetKeyboardType(0)
Select Case k
Case 1
ktype = "IBM PC/XT 或兼容(83键)键盘"
Case 2
ktype = "Olivetti 102键键盘"
Case 3
ktype = "IBM PC/AT 或兼容(84键)键盘"
Case 4
ktype = "IBM增强(101或102)键盘"
Case 5
ktype = "Nokia 1050和类似键盘"
Case 6
ktype = "Nokia 9140和类似键盘"
Case 7
ktype = "Japanese键盘"
End Select
Label1.Caption = "键盘类型:" & ktype
q = SystemParametersInfo&(spi_getkeyboarddelay, 0, r, 0)
Label2.Caption = "键盘延迟时间:" & r & "秒"
q = SystemParametersInfo&(spi_getkeyboardspeed, 0, r, 0)
Label3.Caption = "键盘重复速度:" & " 每秒 " & r & " 次"
Timer1.Interval = GetCaretBlinkTime
Label4.Caption = "光标闪烁速度:" & GetCaretBlinkTime & "毫秒"
End Sub
Private Sub Timer1_Timer()
Line1.Visible = Not Line1.Visible
End Sub
[此贴子已经被作者于2007-3-1 20:11:45编辑过]