Thread View: borland.public.cppbuilder.nativeapi
3 messages
3 total messages
Started by Jeff Kish
Sat, 28 Oct 2006 03:53
hook / global hook question
Author: Jeff Kish
Date: Sat, 28 Oct 2006 03:53
Date: Sat, 28 Oct 2006 03:53
12 lines
1246 bytes
1246 bytes
Hi. I see Matt Pietraks articel from 1997 about how to hook mouse messages globally. I hear there is alot of overhead because the dll gets loaded with every application. Is there any way to code it up so it only gets loaded with selected apps (I'd like to get the mouse wheel working for my old borland 5.02 compiler, and my intellimouse driver isn't doing the trick), so I thought I'd write a dll. Thanks Jeff
Re: hook / global hook question
Author: Remy Lebeau (TeamB)
Date: Sat, 28 Oct 2006 06:24
Date: Sat, 28 Oct 2006 06:24
32 lines
2349 bytes
2349 bytes
"Jeff Kish" <kishjjrjj@charter.net> wrote in message news:fuk5k254ku9car1evv300lnmosb2re3se8@4ax.com... > I see Matt Pietraks articel from 1997 about how to hook mouse > messages globally. I hear there is alot of overhead because the > dll gets loaded with every application. I don't know if I would call it "alot" of overhead, but a global hook DLL does get injected into every running process, and can cause each application to slow down if the hook is not performing efficient operations. > Is there any way to code it up so it only gets loaded with > selected apps You would need to code the DLL's DllEntryPoint() function to dynamically determine the application that is currently loading it, and then return FALSE to cancel the loading if needed. You can use GetModuleFileName(), specifying NULL as the module handle, to get the filename of the process that is currently loading the DLL. A less intrusion approach would be for your main application to monitor all running processes, and then install thread-specific hooks for each desired application when they start up. Enumerating the running processes will give you the thread IDs of each process, and SetWindowsHookEx() can be used to set up a single hook in a specific thread of an external application. Since your main application, not the DLL, would be filtering the processe and threads, the DLL would not be injected into unwanted applications, thus reducing system resource usage. Gambit
Re: hook / global hook question
Author: Jeff Kish
Date: Sun, 29 Oct 2006 03:22
Date: Sun, 29 Oct 2006 03:22
45 lines
2873 bytes
2873 bytes
On Fri, 27 Oct 2006 23:24:04 -0700, "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com> wrote: > >"Jeff Kish" <kishjjrjj@charter.net> wrote in message >news:fuk5k254ku9car1evv300lnmosb2re3se8@4ax.com... > >> I see Matt Pietraks articel from 1997 about how to hook mouse >> messages globally. I hear there is alot of overhead because the >> dll gets loaded with every application. > >I don't know if I would call it "alot" of overhead, but a global hook DLL >does get injected into every running process, and can cause each application >to slow down if the hook is not performing efficient operations. > >> Is there any way to code it up so it only gets loaded with >> selected apps > >You would need to code the DLL's DllEntryPoint() function to dynamically >determine the application that is currently loading it, and then return >FALSE to cancel the loading if needed. You can use GetModuleFileName(), >specifying NULL as the module handle, to get the filename of the process >that is currently loading the DLL. > >A less intrusion approach would be for your main application to monitor all >running processes, and then install thread-specific hooks for each desired >application when they start up. Enumerating the running processes will give >you the thread IDs of each process, and SetWindowsHookEx() can be used to >set up a single hook in a specific thread of an external application. Since >your main application, not the DLL, would be filtering the processe and >threads, the DLL would not be injected into unwanted applications, thus >reducing system resource usage. > > >Gambit I mostly just want my mouse wheel to work with my creaky old borland 5.02 compiler/ide, but I'd write the code with maybe cbuilder to do it. I guess I'd write an app that I put in my startup menu that monitors whenever bc5 is started and use setwindowshoodex like you mentioned. Thanks for the thoughts. >
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads