Click here to get back home

Separate .NET EXEs installing a WH_KEYBOARD_LL keyboard hook on Windows Mobile 5 Smartphone - second hook fails with win32 error code 31 A device attached to the system is not functioning.

 HomeNewsGroups | Search | About
 microsoft.public.smartphone.developer    Post an article   get this group's latest topics as an RSS feed add this group's latest topics to your My MSN content add this group's latest topics to your My Yahoo content
Subject Author Date
Separate .NET EXEs installing a WH_KEYBOARD_LL keyboard hook on Windows Mobile 5 Smartphone - second hook fails with win32 error code 31 A device attached to the system is not functioning. robf 08-24-2006
Get Chitika Premium
Posted by robf on August 24, 2006, 6:15 pm
Please log in for more thread options
I have two .NET EXEs both installing a WH_KEYBOARD_LL keyboard hook on
Windows Mobile 5 Smartphone and the second EXE fails to create it's
hook; GetLastError returns 31, which means "A device attached to the
system is not functioning."

The hook code is wrapped in a hook class and the SetWindowsHookEx call
looks like this:

hookDeleg = new HookProc(HookProcedure);
hHook = SetWindowsHookEx(WH_KEYBOARD_LL, hookDeleg,
GetModuleHandle(null), 0);

Both EXEs have a COPY of the hook class that creates the hook. EXE 1
is using a DLL 1 that contains the hook class. EXE 2 is using DLL 2
that contains the a copy of the same hook class. However, DLL 2 is
shared by both EXE 1 and EXE 2 for different reasons, even though they
are not sharing the same hook class, etc.--both hook classes are in
separate DLLs.

I thought there might be an issue in sharing the same DLL, so I created
copies and separate libraries to cojntain the hook code for each EXE.
Since I am passing GetModuleHandle(null) for the HINSTANCE parameter,
according to the MSDN documentation, it should end up using the calling
executable's HINSTANCE.

So... why would the 2nd hook fail? Is it a problem that DLL 2 is
referenced/used by both EXE 1 and EXE 2, and since EXE 2's hook class
lives there--the hook fails?

Does anyone have any idea about what is going on?

All mentioned EXEs/DLLs are .NET CF 2.0 SP1 assemblies.

Thanks,

Rob


Similar ThreadsPosted
keyboard hook and eating the Home key press on smartphone / Windows Mobile 5 August 3, 2006, 9:53 am
Access violation using a keyboard Hook April 25, 2006, 8:31 am
system wide hook December 27, 2005, 11:49 am
how to issue a hook flash in mobile tapi? December 6, 2006, 11:33 am
IGraphbuilder::RenderFile fails with error code VFW_E_CANNOT_RENDER for .mp3 files June 18, 2008, 3:44 pm
Problem Installing Windows Mobile 5.0 Smartphone SDK September 29, 2005, 1:17 pm
Is there a solution to hook API on WM5/WM6? August 12, 2007, 3:42 am
Hook Window Proc? June 8, 2005, 5:08 pm
SetWindowsHookEx, Hook and Key logger June 14, 2005, 4:08 pm
Notification Hook Examples? March 3, 2007, 10:59 am

Our other projects:

Art Dolls, Fairies and Mermaids - Sunnyfaces.net

Roy's Linux, Programming and Search Engines messages

1-Script XML SitemapXML Sitemap