キーボードに関する情報取得          <TOP>


GetKeyboardType 現在のキーボードに関する情報を取得

 

'================================================================
'= キーボードに関する情報取得
'=    (GetKeyboardType.bas)
'================================================================
#include "Windows.bi"

' 現在のキーボードに関する情報を取得
Declare Function Api_GetKeyboardType& Lib "user32" Alias "GetKeyboardType" (ByVal nTypeFlag&)

Var Shared Text1 As Object
Var Shared List1 As Object
Var Shared Button1 As Object

Text1.Attach GetDlgItem("Text1") : Text1.SetFontSize 14
List1.Attach GetDlgItem("List1") : List1.SetFontSize 12
Button1.Attach GetDlgItem("Button1") : Button1.SetFontSize 14

'================================================================
'=
'================================================================
Declare Sub Button1_on edecl ()
Sub Button1_on()
    Var KeyboardType As Long
    Var KeyboardSubType As Long
    Var FunctionKeys As Long

    'リストボックスをクリア
    List1.Resetcontent

    'キーボードタイプを取得
    KeyboardType = Api_GetKeyboardType(0)

    'キーボードタイプを表示
    Select Case KeyboardType
        Case &H1
            List1.AddString "Type    :IBM(R) PC/XT(R) keyboard"
        Case &H2
            List1.AddString "Type    :Olivetti(R) 'ICO' keyboard"
        Case &H3
            List1.AddString "Type    :IBM PC/AT(R) keyboard"
        Case &H4
            List1.AddString "Type    :IBM enhanced keyboard"
        Case &H5
            List1.AddString "Type    :Nokia(R) 1050 keyboard"
        Case &H6
            List1.AddString "Type    :Nokia9140 keyboard"
        Case &H7
            List1.AddString "Type    :Japanese keyboard"
        Case &H8
            List1.AddString "Type    :Korean keyboard"
    End Select

    'キーボードタイプが日本語文字のキーボードのとき
    If KeyboardType = &H7 Then
        'キーボードサブタイプを取得
        KeyboardSubType = Api_GetKeyboardType(1)

        'キーボードサブタイプによって分岐
        Select Case KeyboardSubType
            'Microsoft(DOS/V)
            Case &H0
                List1.AddString "SubType :PC/AT 101 Enhanced keyboard"
            Case &H1
                List1.AddString "SubType :AX compatible keyboard"
            Case &H2
                List1.AddString "SubType :PC/AT 106 Japanese keyboard"
            Case &H3
                List1.AddString "SubType :IBM 5576-002 keyboard"
            Case &H4
                List1.AddString "SubType :IBM 5576-001 keyboard"
            'AX consortium
            Case &H11
                List1.AddString "SubType :AX keyboard"
            'Fujitsu
            Case &H50
                List1.AddString "SubType :FMR JIS Keyboard"
            Case &H51
                List1.AddString "SubType :FMR OASYS Keyboard"
            Case &H52
                List1.AddString "SubType :PC/AT OASYS Keyboard"
            'NEC
            Case &HD01
                List1.AddString "SubType :PC-9800 standard keyboard"
            Case &HD04
                List1.AddString "SubType :PC-9800 note/laptop keyboard"
            Case &HD05
                List1.AddString "SubType :PC-9800 106 Japanese keyboard"
            'Toshiba
            Case &H1201
                List1.AddString "SubType :Toshiba desktop type keyboard"
            Case &H1202
                List1.AddString "SubType :Toshiba laptop type keyboard"
            '不明
            Case Else
                List1.AddString "SubType :Unknown"
        End Select
    Else
        List1.AddString "SubType :Unjapanese"
    End If

    'ファンクションキー数を取得
    FunctionKeys = Api_GetKeyboardType(2)

    'ファンクションキー数を表示
    List1.AddString "FuncKeys:" & Trim$(Str$(FunctionKeys))
End Sub

'================================================================
'=
'================================================================
While 1
    WaitEvent
Wend
Stop
End