Article View: comp.windows.ms.programmer
Article #932Hook functions (Question)
From: Robert Nee
Date: Wed, 19 Dec 1990 16:32
Date: Wed, 19 Dec 1990 16:32
43 lines
2232 bytes
2232 bytes
I am having a problem implementing a Hook function in windows. I feel
I must be doing something wrong. I have two programs that both install
WH_GETMESSAGE hooks. Either will work fine by itself but if I run
both it seems that the second program (it doesn't matter which one)
prevents the first's hook function from getting called. Both hook
functions are in DLLs and have a structure similar to the following:
void FAR PASCAL Hook (int iCode, WORD wParam, DWORD lParam)
{
if (iCode >= 0) {
/* Check if the message is something I'm interested in
}
else {
DefHookProc (iCode, wParam, lParam, NextHook)
}
where NextHook is a pointer to a pointer to the next hook. Even if this
nexthook parameter is wrong it shouldn't matter because each program
installs only one hook. The documentation claims that this NextHook is
only for multiple hooks in one program. Is this correct?
This routine also only passes control to DefHookProc if it doesn't
proccess the message itself. Is this correct? Do you need to ALWAYS
call DefHookProc at the end of your routine?
SetWindowsHook returns the Proc Instance of the previous hook function
installed. Do I need to call that function manually when I am done?
(the sample above does not do that)
I am certain I am installing these functions properly. And they are in
DLLs as recomended. One final question; If the application is not really
designed for real mode can I place the hook function in my main program,
or more specifically a non-discardable segment of my program without any
side effects?
Any help on this subject would be appreciated. I am working on several
utilities that I hope many users will find useful. Any assistance would
furthur that effort.
Thank you.
Robert Nee
Technical Details
Message-ID:
<143@cf_su20.cf_su10.Sbi.COM>Path:
arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!sbi!zeus!cf_su10!cf_su14!neeShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!censor!geac!torsqnt!news-server.csri.toronto.edu!cs.utexas.edu!uunet!sbi!zeus!cf_su10!cf_su14!nee From: nee@cf_su14.Salomon.Com (Robert Nee) Newsgroups: comp.windows.ms.programmer Subject: Hook functions (Question) Message-ID: <143@cf_su20.cf_su10.Sbi.COM> Date: 19 Dec 90 16:32:56 GMT Sender: news@cf_su10.Sbi.COM Reply-To: nee@cf_su14.Salomon.Com (Robert Nee) Organization: Salomon Brothers, NY Lines: 43