|
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
|