From: mac10 on
I successfully use

SetWindowsHookEx(WH_MOUSE,MouseProc_,0,GetCurrentThreadId());

to set a hook for mouse messages in my application.

In the handler function I react on the WM_MOUSEWHEEL message and work with
the mouseData member to determine the wheel delta etc.
....
MOUSEHOOKSTRUCTEX* pdata = (MOUSEHOOKSTRUCTEX*)lParam;
if (wParam == WM_MOUSEWHEEL) {
WORD h = HIWORD(pdata->mouseData);
WORD l = LOWORD(pdata->mouseData);
}
....

My application is 32 Bit.

This code works flawlessy under 32-Bit Windows versions, but fails under
Windows 7 64-Bit.

The data in the pdata->mouseData member appears to be rubbish, it contains
no valid wheel delta values or flags at all.

This looks like a bug in Windows to me, most likely in the WoW64 which
marshalls the hook from 64 to 32 bit..

Any ideas how to get this working or fixed?


From: Tim Roberts on
mac10 <mac10(a)discussions.microsoft.com> wrote:
>
>I successfully use
>
>SetWindowsHookEx(WH_MOUSE,MouseProc_,0,GetCurrentThreadId());
>
>to set a hook for mouse messages in my application.
>
>In the handler function I react on the WM_MOUSEWHEEL message and work with
>the mouseData member to determine the wheel delta etc.
>...
>My application is 32 Bit.
>
>This code works flawlessy under 32-Bit Windows versions, but fails under
>Windows 7 64-Bit.
>
>The data in the pdata->mouseData member appears to be rubbish, it contains
>no valid wheel delta values or flags at all.
>
>This looks like a bug in Windows to me, most likely in the WoW64 which
>marshalls the hook from 64 to 32 bit..

There is no marshalling. Check the documentation. You can't insert a
32-bit hook into a 64-bit process, nor can you insert a 64-bit hook into a
32-bit process. If you want to capture both, then you need to create a
32-bit DLL and a 64-bit DLL, and they have to have different DLL names.
--
Tim Roberts, timr(a)probo.com
Providenza & Boekelheide, Inc.
From: Richard Russell on
On Jun 8, 6:59 am, Tim Roberts <t...(a)probo.com> wrote:
> There is no marshalling.  Check the documentation.  You can't insert a
> 32-bit hook into a 64-bit process, nor can you insert a 64-bit hook into a
> 32-bit process.  If you want to capture both, then you need to create a
> 32-bit DLL and a 64-bit DLL, and they have to have different DLL names.

The OP appears to be installing his hook only for the current thread;
therefore it's not a global hook and doesn't need to be in a DLL. I
can't see anything in the documentation that suggests a local 32-bit
hook, with its procedure in the same module as the calling
application, won't work correctly under WoW64.

Richard.
http://www.rtrussell.co.uk/