Hi all expert,
I looked everywhere in MSDN to find how i can intercept the key "phone" (green key).
I am a loser cos i can't know how i can do that. I want that when i click the key
"phone" in the device, it will runs my application instead of phone application.
Can you give me some instruction.
I am impatient to hear from you.
JulienT

Hook keybord for pocket pc and smart phone of version 2003, 2005
Najam-x
http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnppcgen/html/migration_developers_faq.asp
Why does an API call to SetWindowsHookEx no longer work in Windows Mobile 5.0
Even though it is not supported or documented, some developers were able to use SetWindowsHookEx with WH_KEYBOARD_LL to intercept keyboard input on Windows Mobile software through Windows Mobile 2003 Second Edition. With Windows Mobile 5.0, this is now considered a privileged API call.
horatiu
I'm sorry but I don't have here a WM05 device to do some testing but I hope there is a way to still intercept all key presses because this is a must for people like me that implements kiosk mode applications...
Any idea from the Masters
ciao
Pietro
ancu
Ok, SetWindowsHookEx is gone.
Alternatives
Have we to develop a custom keyboard driver to handle it
BTW: what does it means that it is now considered a privileged call
Pietro
DaveAnson
As usual, my fault not to look for some docs previously.
This document explain what has been done on WM05 to improve application security:
http://msdn.microsoft.com/library/default.asp url=/library/en-us/dnppcgen/html/wmsecurity.asp
and explain the required steps to sign an application.
I think that a kiosk mode application has to be signed and trusted to be used on a device (at least you have to trust an application that take over your device) so I don't think that having keyboard hook on the "Trusted API" field is a bad idea.
This is even more true for industrial application on rugger hardware where, usually, you sell HW+SW+services as a turnkey solution.
BTW: what I mean for keyboard device driver I'm an embedded guy (from the "the best OS is no OS at all" school) so, usually, if I can't find a solution at the current API layer I start to dig... (this worked for TAPI vs RIL).
best regard
Pietro
Mike H726
for nibble:
i don't know info below will let some idea or not
-- Microsoft define An privileged application is signed with a certificate that is in the privileged certificate store on the device. An unprivileged application is signed with a certificate that is in the unprivileged certificate store on the device.An application that is unsigned has no certificate.
-- Privileged certificate means a certificate that is in the privileged certificate store on the device. Note that there is nothing intrinsic to the certificate itself that is privileged. It is only the presence of the certificate in the privileged certificate store on a particular device that makes the certificate privileged.
Note that the terms trusted and normal refer to how an application runs, whereas privileged, unprivileged, and unsigned refer to how an application is signed. This is an important distinction, for example, it is entirely possible to have an unsigned application run trusted.
What do you intend to do which "custom keyboard driver" I can give you a hand.
John avis
Hi,
Thank for your instruction.
Actually, it runs very well in pocket pc 2003 and smart phone 2003.
But in smart phone 2005 and pocket pc 2005, it can't run.
After get the error with GetLastError() for SetWindowHookEx(), i got
error = 5; it means that Access denied.
So i think that microsoft try to not allow us to intercept the keyboard
By anyway, thank you so much for your instruction.
JulienT
Swati@Mastek
Simon M
You can find the code in old messages of the microsoft.public.windowsce.app.development, as this:
http://groups.google.com/group/microsoft.public.windowsce.app.development/browse_thread/thread/e0243550d63d8f63/2bba7323170c798a lnk=st&q=pocket+pc+SetWindowsHookExW&rnum=5#2bba7323170c798a
Where you will find this code:
extern "C"
{
typedef LRESULT (CALLBACK* HOOKPROC)(int code, WPARAM wParam, LPARAM lParam);
typedef struct tagKBDLLHOOKSTRUCT
{
DWORD vkCode; // virtual key code
DWORD scanCode; // scan code
DWORD flags; // flags
DWORD time; // time stamp for this message
DWORD dwExtraInfo; // extra info from the driver or keybd_event
} KBDLLHOOKSTRUCT, *PKBDLLHOOKSTRUCT;
HHOOK WINAPI SetWindowsHookExW( int idHook, HOOKPROC lpfn, HINSTANCE hmod, DWORD dwThreadId );
BOOL WINAPI UnhookWindowsHookEx( HHOOK hhk );
LRESULT WINAPI CallNextHookEx( HHOOK hhk, int nCode, WPARAM wParam, LPARAM lParam );
LRESULT CALLBACK KeyboardProc( int code, WPARAM wParam, LPARAM lParam );
#define SetWindowsHookEx SetWindowsHookExW
#define HC_ACTION 0
#define APP1_KEY 0xC1
#define APP2_KEY 0xC2
#define APP3_KEY 0xC3
#define APP4_KEY 0xC4
#define APP5_KEY 0xC5
//Notification Code
LRESULT CALLBACK KeyboardProc( int code, WPARAM wParam, LPARAM lParam )
{
PKBDLLHOOKSTRUCT pKeyStruct = (PKBDLLHOOKSTRUCT)lParam;
LRESULT lResult = 0;
if ((AfxGetMainWnd()->m_hWnd != NULL) &&
(code == HC_ACTION) &&
(wParam == WM_KEYDOWN) )
{
switch(pKeyStruct->vkCode )
{
case APP1_KEY:
case APP2_KEY:
case APP3_KEY:
case APP4_KEY:
case APP5_KEY:
lResult = 1;
break;
}
}
if (0 == lResult)
lResult = CallNextHookEx(hKeyboardHook, code, wParam, lParam);
// Return true if hook was handled, false to pass it on
return lResult;
{
CView::OnInitialUpdate();
hKeyboardHook = SetWindowsHookExW( WH_KEYBOARD_LL,
(HOOKPROC) KeyboardProc, // address of hook procedure
NULL, // handle to application instance
0 );
{
if (0 != hKeyboardHook)
UnhookWindowsHookEx(hKeyboardHook);
return CView::DestroyWindow();
You have to "hook the keyboard". To find the correct key code you can debug or log all the key you intercept.
BTW: Hooks are not documented on WinCE (is this changed in WinCE 5.0 / WM 5 ) but the keyboard hook works.
ciao
Pietro