HOW TO: Detect a hardware keyboard
I recently received an email from Idelso, a .NET Compact Framework developer asking:
Q:
How can we, programmatically, detect (for Pocket PC OS) if a PDA or phone has a built-in keyboard, so we do not have to use the Soft Input Panel (SIP) control? I have been looking around for the answer, but I haven't been successful yet.
A:
There are two ways:
1) P/Invoke GetKeyboardStatus() - this is the preferred method but may not work as some OEMs have not been implementing it - this will change with the advent of Pocket PC devices with keyboards,
2) query the registry for a HasKeyboard key in the “HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Shell” hive (or whatever it is called) - please note that this method is unsupported and may change in the future (as OEMs implement GetKeyboardStatus). Download the P/Invoke Libray sample for the code.
Geoff Schwab who many of you may know from the .NET Compact Framework newsgroup has added sample code for both approaches to the “Create a P/Invoke Library” whitepaper and sample in the .NET Compact Framework section of the MSDN Library. The article will not be refreshed until next week but the sample code download has been refresh and is available here. We will also update the .NET Compact Framework FAQ next week.
Thanks for the question Idelso! If you have encountered a problem that you think deserves a FAQ entry please let us know by send email to netcfaq@microsoft.com.
Comments
- Anonymous
March 14, 2004
Jono:
Thank you very much for your quick reply! As i said in my original e-mail, it is wonderful to have a place where we can exchange ideas, questions and comments, as well as hearing from you on the latest developments.
Regards,
Idelso Quintero - Anonymous
July 01, 2004
how can i use a sip window with getting the hardware keyboard messages? i can't let my sip window get the focus. - Anonymous
June 15, 2009
PingBack from http://mydebtconsolidator.info/story.php?id=18492