BorlandTalk.com Forum Index BorlandTalk.com
Borland discussion newsgroups
 
Archives   FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

hook / global hook question

 
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API)
View previous topic :: View next topic  
Author Message
Jeff Kish
Guest





PostPosted: Sat Oct 28, 2006 8:10 am    Post subject: hook / global hook question Reply with quote



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
Back to top
Remy Lebeau (TeamB)
Guest





PostPosted: Sat Oct 28, 2006 8:10 am    Post subject: Re: hook / global hook question Reply with quote



"Jeff Kish" <kishjjrjj (AT) charter (DOT) net> wrote in message
news:fuk5k254ku9car1evv300lnmosb2re3se8 (AT) 4ax (DOT) com...

Quote:
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.

Quote:
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
Back to top
Jeff Kish
Guest





PostPosted: Sun Oct 29, 2006 8:22 am    Post subject: Re: hook / global hook question Reply with quote



On Fri, 27 Oct 2006 23:24:04 -0700, "Remy Lebeau \(TeamB\)"
<no.spam (AT) no (DOT) spam.com> wrote:

Quote:

"Jeff Kish" <kishjjrjj (AT) charter (DOT) net> wrote in message
news:fuk5k254ku9car1evv300lnmosb2re3se8 (AT) 4ax (DOT) 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.


>
Back to top
Display posts from previous:   
Post new topic   Reply to topic    BorlandTalk.com Forum Index -> C++ Builder (Native API) All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2006 phpBB Group
SEO toolkit © 2004-2006 webmedic.