🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Establishing a Keyboard Hook.........

#2989
From: qyte
Date: Tue, 05 Sep 2006 09:46
42 lines
2415 bytes
Bob Gonder wrote:
> qyte wrote:
> 
>> I have built the following DLL...
>>
>> #include <vcl.h>
> 
> Why include vcl.h? You don't show any vcl code in the dll.
> 
>> int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void* lpReserved)
>> {
> 
> "hinst" is the module handle for this dll.
> 
>> __declspec(dllexport) bool installhook(HWND hwnd)
>> {
>>     hkb=SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)KeyboardProc,HInstance,0);
> 
> HInstance is probably the handle of the application, not the DLL,
> which you need.
> 
>> Why is this not working? What on earth am i doing wrong?
>> It only captures keystrokes from within my application...
> 
> Probably because you are installling the hook for the application
> instance, not the DLL instance.
> 
> See also GetModuleHandle()
> 
> 

No you are wrong... :(
I Tested it and HInstance returns the same exact handle as
the LoadLibrary call returns from within the main program...
Apart from that the HInstance within the main app is COMPLETELY
different from that one and the one that LoadLibrary returns
obviously... I will test it anyway the GetModuleHandle() method
anyway just in case... :(

I was rather hasty in my previous post... The code works GREAT
but only if you are interested in catching keyboard strokes within
your application only, which is APPARENTLY UNACCEPTABLE in my case...
Technical Details
Message-ID: <44fd4773$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <44fc9f3a@newsgroups.borland.com> <pf6qf2d54g6cq331ifq5bvrph2jrdhguiv@4ax.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,25dce3f6aa4fede9
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
Date: Tue, 05 Sep 2006 12:46:27 +0300
From: qyte <gyte@vivodinet.gr>
User-Agent: Thunderbird 1.5.0.5 (Windows/20060719)
MIME-Version: 1.0
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Establishing a Keyboard Hook.........
References: <44fc9f3a@newsgroups.borland.com> <pf6qf2d54g6cq331ifq5bvrph2jrdhguiv@4ax.com>
In-Reply-To: <pf6qf2d54g6cq331ifq5bvrph2jrdhguiv@4ax.com>
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 88.218.20.114
Message-ID: <44fd4773$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1157449587 88.218.20.114 (5 Sep 2006 02:46:27 -0700)
Lines: 42
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newspeer1.nwr.nac.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail