DeletedUser14087 I post too much
Reputation: 2
Joined: 21 Jun 2006 Posts: 3069
|
Posted: Fri Apr 25, 2008 7:09 am Post subject: [Delphi + C]Retrive your Keyboard Type / Num of Functions |
|
|
Here's something neat i wrote in like.. 10min, using GetKeyboardType() API.
feel free to edit, do w.e you want with it, not that hard.
Quote: | unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
Procedure Msg(Text:String);
begin
ShowMessage(Text);
End;
procedure TForm1.Button1Click(Sender: TObject);
const NLine = #10#13; //New Line (\n)
var GKT,GKFN:Integer; //GKT = Getting the Type of the Keybd
//GKFN = Getting the num of func on your Keybd
nTypeFlag,nTypeFlag2:Integer;
P,P2:ShortString;
begin
P:='Your keyboard type is: ';
P2:='The Number Of Your Keyboard Functions Is: ';
nTypeFlag:=0;
nTypeFlag2:=2;//0 = Keybd Type
//1 = Keybd subtype (optional)
//2 = Num of functions on the Keybd
GKT:=GetKeyBoardType(nTypeFlag); //GetKeyboardType(); Win32 API
GKFN:=GetKeyBoardType(nTypeFlag2); //GetKeyboardType(); Win32 API
case GKT and GKFN of
1:Msg(P+'IBM® PC/XT® ( ) or compatible (83-key) keyboard'+NLine+P2+'10');
2:Msg(P+'Olivetti® "ICO" (102-key) keyboard'+NLine+P2+'12 or 18');
3:Msg(P+'IBM PC/AT® (84-key) or similar keyboard'+NLine+P2+'10');
4:Msg(P+'IBM enhanced (101- or 102-key) keyboard'+NLine+P2+'12');
5:Msg(P+'Nokia® 1050 and similar keyboards'+NLine+P2+'10');
6:Msg(P+'Nokia 9140 and similar keyboards'+NLine+P2+'24');
7:Msg(P+'Japanese keyboard'+NLine+P2+'Hardware dependent and specified by the OEM'); //Not sure what type of keyboard is that lol
end;
{case GKFN of
1:Msg(P2+'10');
2:Msg(P2+'12 or 18');
3:Msg(P2+'10');
4:Msg(P2+'12');
5:Msg(P2+'10');
6:Msg(P2+'24');
7:Msg('Hardware dependent and specified by the OEM');
end;}
end;
end. |
just for the people who wanna learn, and learn how to use the case/of in delphi (switch/case C)
C wrote: | #include <windows.h>
#include <stdio.h>
int main(void)
{
int lol = GetKeyboardType(0);
switch(lol)
{
case 1:
printf("IBM® PC/XT® ( ) or compatible (83-key) keyboard\n");
break;
case 2:
printf("Olivetti® 'ICO' (102-key) keyboard\n");
break;
case 3:
printf("IBM PC/AT® (84-key) or similar keyboard\n");
break;
case 4:
printf("IBM enhanced (101- or 102-key) keyboard\n");
break;
case 5:
printf("Nokia® 1050 and similar keyboards\n");
break;
case 6:
printf("Nokia 9140 and similar keyboards\n");
break;
case 7:
printf("Japanese keyboard\n");
break;
default:
printf("WTF are you using ???\n");
}
return EXIT_SUCCESS;
} |
|
|