jamesc@dbase.A-T.COM (James Chuang ) (05/22/91)
Hello world: I'm trying to use SetWindowsHook() in a DLL. I've been trying to use GetProcAddress() to get the address of the callback function. No luck. It always returns 0 for the address, which is pretty useless. I have made sure of the following: callback function is exported in the DLL's .def file the name is correct, I have tried all variations there... I've even tried to explicitly load the library with LoadLibrary, then use the library handle to call GetProcAddress(). All I get there is a UAE. I've also tried using the ordinal numbers defined in the .def, no luck there. How can it be done.....? thanks jamesc #include <disclaimer.h>
jamesc@dbase.A-T.COM (James Chuang ) (05/22/91)
Okay, I got a hook of JOURNALRECORD going. The only thing the callback function does is call Messagebeep() currently. So as I move the mouse, the machine beeps like crazy. However, as soon as I launch an app, such as Notepad, a UAE comes up, and the system hard crashes. CVW shows a failure somewhere in windows. Would anyone please share experience in using JOURNALRECORD? Also, since SetWindowsHook() returns NULL for the next filter in chain, does my callback function need to call DefWindowsHook? if so, what do I call it with? Is there a good book with all this in it? I know Petzold`s doesn't address this.... thanks jamesc #include <disclaimer.h>
bonneau@hyper.hyper.com (Paul Bonneau) (05/23/91)
In article <1991May21.205525.10557@dbase.A-T.COM> jamesc@dbase.UUCP (James Chuang ) writes: >Hello world: >I'm trying to use SetWindowsHook() in a DLL. I've been trying to use >GetProcAddress() to get the address of the callback function. No luck. >It always returns 0 for the address, which is pretty useless. I have >made sure of the following: > callback function is exported in the DLL's .def file > the name is correct, I have tried all variations there... > >I've even tried to explicitly load the library with LoadLibrary, then >use the library handle to call GetProcAddress(). All I get there is a UAE. >I've also tried using the ordinal numbers defined in the .def, no luck there. > >How can it be done.....? > The only thing I can think of to look out for is that the code segment containing the hook function must be fixed (see page 20.2.3 of the "Guide to Programming". cheers - Paul Bonneau.
bonneau@hyper.hyper.com (Paul Bonneau) (05/24/91)
In article <1991May22.145944.27437@dbase.A-T.COM> jamesc@dbase.UUCP (James Chuang ) writes: > >Okay, I got a hook of JOURNALRECORD going. The only thing the callback >function does is call Messagebeep() currently. So as I move the mouse, the >machine beeps like crazy. >However, as soon as I launch an app, such as Notepad, a UAE comes up, and >the system hard crashes. CVW shows a failure somewhere in windows. Would >anyone please share experience in using JOURNALRECORD? >Also, since SetWindowsHook() returns NULL for the next filter in chain, >does my callback function need to call DefWindowsHook? if so, what >do I call it with? >Is there a good book with all this in it? I know Petzold`s doesn't address >this.... Things to look out for: * Make sure your hook function calls DefHookProc() whenever nCode is less than 0. * Make sure the code segment containing the hook function is fixed. Call DefHookProc(), even though *lplpfnNextHook == NULL. cheers - Paul Bonneau. P.S. I could tell you more, but the server that contains our source is down right now.
rvd@bunker.isc-br.com (Robert Del Favero Jr.) (05/28/91)
James Chuang writes: >> [ about his problems getting a windows hook routine to work] >>Is there a good book with all this in it? I know Petzold`s doesn't address >>this.... There's a good new book just hitting the bookstores now: Windows 3: A Developer's Guide Jeffrey M. Richter M&T Books ISBN 1-55851-164-4 $39.95, includes 3 360K disks of example programs Richter devotes an entire chapter to a discussion of windows hooks, including some sample code. Other topics include: window subclassing and superclassing dialog box techniques dynamic memory management dynamic link libraries custom child controls printer setup commercial application installation Multiple Document Interface (MDI) (and the examples are littered with useful tidbits) I've read and worked my way through the first three quarters of the book, and I can't recommend it highly enough for those of us who have made it past the level of Petzold's book. I still recommend Petzold first, but Richter makes an excellent second book on Windows programming. (You need at least Volume I of the SDK reference, in any case.) Programming Windows, 2e Charles Petzold Microsoft Press ISBN 1-55615-264-7 $29.95 ------------------------------------------------------------------------------- Robert V. Del Favero, Jr. ISC-Bunker Ramo, an Olivetti Company rvd@clunker.shel.isc-br.com Shelton, Connecticut, USA
Robert.Del.Favero.Jr.@sunbrk.FidoNet.Org (Robert Del Favero Jr.) (05/29/91)
Reply-To: rvd@clunker.UUCP (Robert Del Favero) James Chuang writes: >> [ about his problems getting a windows hook routine to work] >>Is there a good book with all this in it? I know Petzold`s doesn't address >>this.... There's a good new book just hitting the bookstores now: Windows 3: A Developer's Guide Jeffrey M. Richter M&T Books ISBN 1-55851-164-4 $39.95, includes 3 360K disks of example programs Richter devotes an entire chapter to a discussion of windows hooks, including some sample code. Other topics include: window subclassing and superclassing dialog box techniques dynamic memory management dynamic link libraries custom child controls printer setup commercial application installation Multiple Document Interface (MDI) (and the examples are littered with useful tidbits) I've read and worked my way through the first three quarters of the book, and I can't recommend it highly enough for those of us who have made it past the level of Petzold's book. I still recommend Petzold first, but Richter makes an excellent second book on Windows programming. (You need at least Volume I of the SDK reference, in any case.) Programming Windows, 2e Charles Petzold Microsoft Press ISBN 1-55615-264-7 $29.95 ------------------------------------------------------------------------------- Robert V. Del Favero, Jr. ISC-Bunker Ramo, an Olivetti Company rvd@clunker.shel.isc-br.com Shelton, Connecticut, USA * Origin: Seaeast - Fidonet<->Usenet Gateway - sunbrk (1:343/15.0)