GetKeyboardType 依參數 nTypeFlag 回傳三類資訊:0=鍵盤類型 (IBM PC/XT、AT、Enhanced 101/102 鍵等)、1=子類型 (廠商自訂)、2=功能鍵數量 (通常 12,即 F1-F12)。
function GetKeyboardType(nTypeFlag: Integer): Integer; stdcall;
procedure TForm1.FormCreate(Sender: TObject);
var
i: Integer;
List: TStringList;
begin
List := TStringList.Create;
List.Add('IBM PC/XT or compatible (83-key) keyboard');
List.Add('Olivetti "ICO" (102-key) keyboard');
List.Add('IBM PC/AT (84-key) or similar keyboard');
List.Add('IBM enhanced (101/102-key) keyboard');
List.Add('Nokia 1050 and similar keyboards');
List.Add('Nokia 9140 and similar keyboards');
List.Add('Japanese keyboard');
i := GetKeyboardType(0); // 鍵盤類型
ShowMessage(List[i-1]); // 索引從 1 開始,如 4 = Enhanced
i := GetKeyboardType(1); // 子類型
ShowMessage(IntToStr(i)); // 廠商自訂,通常 0
i := GetKeyboardType(2); // 功能鍵數
ShowMessage(IntToStr(i)); // 通常 12
List.Free;
end;
| 回傳值 | 說明 |
|---|---|
| 1 | IBM PC/XT (83 鍵) |
| 2 | Olivetti ICO (102 鍵) |
| 3 | IBM PC/AT (84 鍵) |
| 4 | IBM Enhanced (101/102 鍵) - 最常見 |
| 5 | Nokia 1050 系列 |
| 6 | Nokia 9140 系列 |
| 7 | 日文鍵盤 |
現代鍵盤幾乎皆回傳 4 (Enhanced) 與 12 功能鍵。此 API 適用於需針對特殊鍵盤佈局調整 UI 的舊版相容軟體。