🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#2988
From: Bob Gonder
Date: Tue, 05 Sep 2006 06:40
27 lines
1740 bytes
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()
Technical Details
Message-ID: <pf6qf2d54g6cq331ifq5bvrph2jrdhguiv@4ax.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <44fc9f3a@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10cc67,25dce3f6aa4fede9
X-Google-Attributes: gid10cc67,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: Bob Gonder <notbg@notmindspring.invalid>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Re: Establishing a Keyboard Hook.........
Date: Mon, 04 Sep 2006 23:40:35 -0700
Organization: MindSpring Enterprises, Inc.
Reply-To: notbg@notmindspring.invalid
Message-ID: <pf6qf2d54g6cq331ifq5bvrph2jrdhguiv@4ax.com>
References: <44fc9f3a@newsgroups.borland.com>
X-Newsreader: Forte Agent 1.93/32.576 English (American)
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 69.69.87.29
X-Trace: newsgroups.borland.com 1157438432 69.69.87.29 (4 Sep 2006 23:40:32 -0700)
Lines: 29
Path: arc1-ca.pugleaf.net!g2news2.google.com!news2.google.com!news3.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newshub.sdsu.edu!logbridge.uoregon.edu!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail