![]() |
AW: Wie erkennen, ob physikalische Tastatur vorhanden
Zitat:
Mit den geeigneten Treibern könntest Du feststellen ob z.B. über die PS2-Schnittstelle eine Tastatur physisch am Rechner hängt. Über USB bekommst Du nur ein HI und das kann physisch alles mögliche sein. Gruß K-H |
AW: Wie erkennen, ob physikalische Tastatur vorhanden
Liste der Anhänge anzeigen (Anzahl: 1)
Wenn man einen Touchscreen hat, kann man z.B.
![]() |
AW: Wie erkennen, ob physikalische Tastatur vorhanden
Wer will, kann mal die beiden WMI-Abfragen vergleichen, ob etwas Eindeutiges auf eine physikalische Tastatur hinweisst.
Delphi-Quellcode:
//-----------------------------------------------------------------------------------------------------
// This code was generated by the Wmi Delphi Code Creator http://theroadtodelphi.wordpress.com // Version: 1.8.3.0 // LIABILITY DISCLAIMER // THIS GENERATED CODE IS DISTRIBUTED "AS IS". NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED. // YOU USE IT AT YOUR OWN RISK. THE AUTHOR NOT WILL BE LIABLE FOR DATA LOSS, // DAMAGES AND LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING OR MISUSING THIS CODE. //---------------------------------------------------------------------------------------------------- program GetWMI_Info; {$APPTYPE CONSOLE} uses (* SysUtils, ActiveX, ComObj, Variants; *) System.SysUtils, Winapi.ActiveX, System.Win.ComObj, System.Variants; function VarToInt(const AVariant: Variant): INT64;// integer; begin Result := StrToIntDef(Trim(VarToStr(AVariant)), 0); end; // Funktionen und Verwaltung der logischen Tastatur. procedure GetCIM_KeyboardInfo; const WbemUser =''; WbemPassword =''; WbemComputer ='localhost'; wbemFlagForwardOnly = $00000020; var FSWbemLocator : OLEVariant; FWMIService : OLEVariant; FWbemObjectSet: OLEVariant; FWbemObject : OLEVariant; oEnum : IEnumvariant; iValue : LongWord; begin; FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); FWMIService := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, WbemPassword); FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM CIM_Keyboard','WQL',wbemFlagForwardOnly); oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant; while oEnum.Next(1, FWbemObject, iValue) = 0 do begin Writeln(Format('Availability %d',[VarToInt(FWbemObject.Availability)]));// Uint16 Writeln(Format('Caption %s',[VarToStr(FWbemObject.Caption)]));// String Writeln(Format('ConfigManagerErrorCode %d',[VarToInt(FWbemObject.ConfigManagerErrorCode)]));// Uint32 Writeln(Format('ConfigManagerUserConfig %s',[VarToStr(FWbemObject.ConfigManagerUserConfig)]));// Boolean Writeln(Format('CreationClassName %s',[VarToStr(FWbemObject.CreationClassName)]));// String Writeln(Format('Description %s',[VarToStr(FWbemObject.Description)]));// String Writeln(Format('DeviceID %s',[VarToStr(FWbemObject.DeviceID)]));// String Writeln(Format('ErrorCleared %s',[VarToStr(FWbemObject.ErrorCleared)]));// Boolean Writeln(Format('ErrorDescription %s',[VarToStr(FWbemObject.ErrorDescription)]));// String Writeln(Format('InstallDate %s',[VarToStr(FWbemObject.InstallDate)]));// Datetime Writeln(Format('IsLocked %s',[VarToStr(FWbemObject.IsLocked)]));// Boolean Writeln(Format('LastErrorCode %d',[VarToInt(FWbemObject.LastErrorCode)]));// Uint32 Writeln(Format('Layout %s',[VarToStr(FWbemObject.Layout)]));// String Writeln(Format('Name %s',[VarToStr(FWbemObject.Name)]));// String Writeln(Format('NumberOfFunctionKeys %d',[VarToInt(FWbemObject.NumberOfFunctionKeys)]));// Uint16 Writeln(Format('Password %d',[VarToInt(FWbemObject.Password)]));// Uint16 Writeln(Format('PNPDeviceID %s',[VarToStr(FWbemObject.PNPDeviceID)]));// String Writeln(Format('PowerManagementCapabilities %d',[VarToInt(FWbemObject.PowerManagementCapabilities)]));// Array of Uint16 Writeln(Format('PowerManagementSupported %s',[VarToStr(FWbemObject.PowerManagementSupported)]));// Boolean Writeln(Format('Status %s',[VarToStr(FWbemObject.Status)]));// String Writeln(Format('StatusInfo %d',[VarToInt(FWbemObject.StatusInfo)]));// Uint16 Writeln(Format('SystemCreationClassName %s',[VarToStr(FWbemObject.SystemCreationClassName)]));// String Writeln(Format('SystemName %s',[VarToStr(FWbemObject.SystemName)]));// String Writeln(''); FWbemObject:=Unassigned; end; end; procedure GetWin32_KeyboardInfo; const WbemUser =''; WbemPassword =''; WbemComputer ='localhost'; wbemFlagForwardOnly = $00000020; var FSWbemLocator : OLEVariant; FWMIService : OLEVariant; FWbemObjectSet: OLEVariant; FWbemObject : OLEVariant; oEnum : IEnumvariant; iValue : LongWord; begin; FSWbemLocator := CreateOleObject('WbemScripting.SWbemLocator'); FWMIService := FSWbemLocator.ConnectServer(WbemComputer, 'root\CIMV2', WbemUser, WbemPassword); FWbemObjectSet:= FWMIService.ExecQuery('SELECT * FROM Win32_Keyboard','WQL',wbemFlagForwardOnly); oEnum := IUnknown(FWbemObjectSet._NewEnum) as IEnumVariant; while oEnum.Next(1, FWbemObject, iValue) = 0 do begin Writeln(Format('Availability %d',[VarToInt(FWbemObject.Availability)]));// Uint16 Writeln(Format('Caption %s',[VarToStr(FWbemObject.Caption)]));// String Writeln(Format('ConfigManagerErrorCode %d',[VarToInt(FWbemObject.ConfigManagerErrorCode)]));// Uint32 Writeln(Format('ConfigManagerUserConfig %s',[VarToStr(FWbemObject.ConfigManagerUserConfig)]));// Boolean Writeln(Format('CreationClassName %s',[VarToStr(FWbemObject.CreationClassName)]));// String Writeln(Format('Description %s',[VarToStr(FWbemObject.Description)]));// String Writeln(Format('DeviceID %s',[VarToStr(FWbemObject.DeviceID)]));// String Writeln(Format('ErrorCleared %s',[VarToStr(FWbemObject.ErrorCleared)]));// Boolean Writeln(Format('ErrorDescription %s',[VarToStr(FWbemObject.ErrorDescription)]));// String Writeln(Format('InstallDate %s',[VarToStr(FWbemObject.InstallDate)]));// Datetime Writeln(Format('IsLocked %s',[VarToStr(FWbemObject.IsLocked)]));// Boolean Writeln(Format('LastErrorCode %d',[VarToInt(FWbemObject.LastErrorCode)]));// Uint32 Writeln(Format('Layout %s',[VarToStr(FWbemObject.Layout)]));// String Writeln(Format('Name %s',[VarToStr(FWbemObject.Name)]));// String Writeln(Format('NumberOfFunctionKeys %d',[VarToInt(FWbemObject.NumberOfFunctionKeys)]));// Uint16 Writeln(Format('Password %d',[VarToInt(FWbemObject.Password)]));// Uint16 Writeln(Format('PNPDeviceID %s',[VarToStr(FWbemObject.PNPDeviceID)]));// String Writeln(Format('PowerManagementCapabilities %d',[VarToInt(FWbemObject.PowerManagementCapabilities)]));// Array of Uint16 Writeln(Format('PowerManagementSupported %s',[VarToStr(FWbemObject.PowerManagementSupported)]));// Boolean Writeln(Format('Status %s',[VarToStr(FWbemObject.Status)]));// String Writeln(Format('StatusInfo %d',[VarToInt(FWbemObject.StatusInfo)]));// Uint16 Writeln(Format('SystemCreationClassName %s',[VarToStr(FWbemObject.SystemCreationClassName)]));// String Writeln(Format('SystemName %s',[VarToStr(FWbemObject.SystemName)]));// String Writeln(''); FWbemObject:=Unassigned; end; end; begin try CoInitialize(nil); try GetCIM_KeyboardInfo; WriteLn('----------------------------------------------------------------'); GetWin32_KeyboardInfo; finally CoUninitialize; end; except on E:EOleException do Writeln(Format('EOleException %s %x', [E.Message,E.ErrorCode])); on E:Exception do Writeln(E.Classname, ':', E.Message); end; Writeln('Press Enter to exit'); Readln; end. |
Alle Zeitangaben in WEZ +1. Es ist jetzt 18:16 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz