🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #71

Re: Setting (and losing) a keyboard hook

#71
From: Remy Lebeau (TeamB)
Date: Thu, 19 Jun 2008 16:59
24 lines
2131 bytes
"salamander1965" <salamander1@verizon.net> wrote in message 
news:4859926a@newsgroups.borland.com...

> However, if I close the first instance before the others, the
> remaining instances no longer respond to the message sent
> by the hook procedure.

Your first instance is likely deactivating the hook during its shutdown, 
thus it is no longer available for any instances that are still running. 
The behavior you desacribe would suggest that the hook is being associated 
with the first instance (per the hMod parameter of SetWindowsHookEx()). 
That instance would have to be the last instance terminated in order for the 
hook to work properly while the other instances are running, as you have 
already seen.

To do what you are attempting, I suggest moving the hook code into a 
separate .exe of its own.  The first instance of your app can launch the 
hook .exe, which then loads the DLL hook.  The last instance of your app can 
terminate the hook .exe, unloading the DLL.  That way, the hook is 
associated with its own process, not any particular instance of your app.


Gambit 
Technical Details
Message-ID: <485a909f$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <4859926a@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,21bdbb7b8038a591
X-Google-Attributes: gid10cc67,domainid0,public,usenet
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Remy Lebeau \(TeamB\)" <no.spam@no.spam.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <4859926a@newsgroups.borland.com>
Subject: Re: Setting (and losing) a keyboard hook
Date: Thu, 19 Jun 2008 09:59:08 -0700
Lines: 26
Organization: Lebeau Software
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.3138
X-RFC2646: Format=Flowed; Response
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.3198
NNTP-Posting-Host: 207.178.157.90
Message-ID: <485a909f$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1213894815 207.178.157.90 (19 Jun 2008 10:00:15 -0700)
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
X-Original-Bytes: 1975