Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

SetWindowsHookEx, system hooks and libraries

1 view
Skip to first unread message

Kevin W. Hammond

unread,
Aug 12, 1994, 6:53:22 PM8/12/94
to
Greetings!

I'm curious as to the specifics of SetWindowsHookEx() ... I have installed
a hook with a NULL htask parameter to fetch system-wide mouse messages.

As long as my main window is visible, the hook is called just fine, regardless
of which program has the focus. However, when I click on a desktop icon my
hook is never called again and I must terminate my program.

The only thing I can think of is the statement in the "Programmer's Reference,
Volume 2: Functions" that says:

"... All system hook functions must be in libraries ..."

Does this mean that my hook function must reside in a DLL? If so, why is it
working "some of the time but not all of the time?"

Any info you might have would be appreciated! I'm really stumpped on this
one!

--kevin
--
Kevin W. Hammond
ham...@image.ctt.com

Kevin W. Hammond

unread,
Aug 12, 1994, 8:09:12 PM8/12/94
to
In article <32guh2$k...@news1.mcs.com>,

Kevin W. Hammond <ham...@ctt.com> wrote:
>
>I'm curious as to the specifics of SetWindowsHookEx() ... I have installed
>a hook with a NULL htask parameter to fetch system-wide mouse messages.
>
>As long as my main window is visible, the hook is called just fine, regardless
>of which program has the focus. However, when I click on a desktop icon my
>hook is never called again and I must terminate my program.
>
>The only thing I can think of is the statement in the "Programmer's Reference,
>Volume 2: Functions" that says:
>
> "... All system hook functions must be in libraries ..."
>
>Does this mean that my hook function must reside in a DLL? If so, why is it
>working "some of the time but not all of the time?"
>

As a followup to my own post ... I did some testing and placed my hook
procedure in a DLL. I now no longer have the problem of getting the hook
procedure called depending on the active application and state.

It also worked well enough to allow me to hide the application's main
window.

James Finnegan

unread,
Aug 16, 1994, 11:19:10 PM8/16/94
to
Kevin,
Since you are installing a callback that resides in your app
(and you want it available on a systemwide basis), you must either place
the function in a DLL, or stop using smart callbacks (prot. mode callback
in MS terms) from your compiler. The reason is that your prolog code must
set the DS register properly upon entry. Smart callbacks set DS based on
the current value in SS, whcih is fine, as long as your app has focus.
In addition, you must also use MakeProcInstance to create an appropriate
instance thunk. For further details, see the sidebar in my article
"Hook and Monitor any 16-bit Windows Function with our ProcHook DLL" from
Microsoft Systems Journal, Jan 1994. That should shed some additional light.

regards
Jim Finnegan
0 new messages