Private Sub Command1_Click()
Dim k,keytype
k = GetKeyboardType(0)
Select Case k
Case 1
keytype = "IBM PC /XT或兼容83键键盘"
Case 2
keytype = "Olivetti102键键盘"
Case 3
keytype = "IBM PC /XT或兼容84键键盘"
Case 4
keytype = "IBM 增强(101 或102键)键盘"
Case 5
keytype = "Nokia1050 键盘"
Case 6
keytype = "Nokia9140 键盘"
Case 7
keytype = "Japanese 键盘"
End Select
Label1.Caption = "键盘类型是:" & keytype
End Sub
Option Explicit
Public Declare Function GetKeyboardType Lib "user32" (ByVal nTypeFlag As Long) As Long
GetKeyboardType:
函数功能:该函数获取系统当前键盘的信息. 函数原型:int GetKeyboardType(int nTypeFlag); 参数说明: nTypeFlag:指定要获取的键盘信息的类型,该参数可以是下面的值之一: 0:键盘的类型; 1:键盘的子类型; 2:键盘上功能键的状态. 注意事项:函数成功将返回用户指定要获取的键盘信息,否则返回零值.键盘的类型与原始设备制造商(OEM)有关,用户还可以从键盘的类型获取键盘上功能键的个数. 头文件:winuser.h 链接库:user32.h