Article View: borland.public.cppbuilder.nativeapi
Article #2902Re: hook / global hook question
From: 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. >
Technical Details
Message-ID:
<4f78k259jm5rdmjmgb70ahpni9jib6e4e2@4ax.com>Path:
arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<fuk5k254ku9car1evv300lnmosb2re3se8@4ax.com> <4542f7f0$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,2c3bbe422461484a X-Google-Attributes: gid10cc67,public X-Google-Language: ENGLISH,ASCII-7-bit From: Jeff Kish <kishjjrjj@charter.net> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: hook / global hook question Date: Sat, 28 Oct 2006 23:22:00 -0400 Message-ID: <4f78k259jm5rdmjmgb70ahpni9jib6e4e2@4ax.com> References: <fuk5k254ku9car1evv300lnmosb2re3se8@4ax.com> <4542f7f0$1@newsgroups.borland.com> X-Newsreader: Forte Agent 3.0/32.763 MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 24.231.255.88 X-Trace: newsgroups.borland.com 1162091875 24.231.255.88 (28 Oct 2006 20:17:55 -0700) Lines: 45 Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news1.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail