Querying presence of a keyboard

  • Thread starter Thread starter Claire
  • Start date Start date
C

Claire

Hi,
Is there any way to query whether or not a keyboard is attached to a pc
please?
My software will be running on XP/Vista systems in an environment where
there may or may not be a keyboard/mouse attached to the system.

thank you
 
I don't know the answer to the question, but I would not think it was
necessary to know the answer to accomplish what you are required to do.

If you have some code XYZ that needs to be executed at some time by a user
action, then presumably the code is executed from some event handler, such as
a button click or keyboard shortcut. It sounds like you will need to make
sure that there is some form of handler for setups where neither of these
could occur, perhaps from a voice activation event? Your mouse and keyboard
handlers just won't be called in this configuration.
 
Claire said:
Hi,
Is there any way to query whether or not a keyboard is attached to a pc
please?

SetupDiCreateDeviceInfoList passing GUID_DEVCLASS_KEYBOARD

I highly recommend using C++/CLI for this as C# code for using C-style
structures with pointers is somewhat unwieldy.
 
Peter Bromberg said:
Forgive me for sounding simplistic, but if there is no keyboard / mouse
attached to a machine running your program then how do you propose to get
user input?
The "sounds" like the classic joke,

"Keyboard not found. Press F1 to continue."

Knowing there is no keyboard... might help prevent such paradoxes. A
timeout could be substituted.
 
Obviously it will come from the same way the user launched the program... :)
 
Lol! in reply to comments about keyboards/mice.
My application is written for touch screen and operates in different modes
depending on user type logging into the system.
Regular users log in at reception using a card via a cardreader and have a
touch screen, admins would normally have an installation with mouse and
keyboard.
I thought it would be nicer to test whether hardware was absent and display
an onscreen keyboard automatically rather than force someone to press an
onscreen button to access it.
thank you :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top