🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

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

#2990
From: Ed Mulroy
Date: Tue, 05 Sep 2006 11:31
56 lines
2610 bytes
Ok, then try changing from this:

----------------------
__declspec(dllexport) bool installhook(HWND hwnd)
{
     hkb = SetWindowsHookEx(
         WH_KEYBOARD,
         (HOOKPROC) KeyboardProc,
         HInstance,
        0);

     Handle = hwnd;
     return hkb;
}

----------------------

To this:

----------------------
// variable created by the compiler's startup code
// instance handle/module handle of the DLL, the same
// value as is passed as a calling arg to DllEntryPoint

extern HINSTANCE _hInstance;

__declspec(dllexport) bool installhook(HWND hwnd)
{
     hkb = SetWindowsHookEx(
         WH_KEYBOARD,
         (HOOKPROC) KeyboardProc,
         _hInstance,
        0);

     Handle = hwnd;
     return hkb;
}

----------------------

.  Ed

> qyte wrote in message
> news:44fd4773$1@newsgroups.borland.com...
>
> 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: <44fd6016$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!news.glorb.com!tudelft.nl!txtfeed1.tudelft.nl!feeder.news-service.com!newsfeed.freenet.de!news.code-werk.net!open-news-network.org!news.soft-gems.net!reader.uucp.at!feeder02.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail
References: <44fc9f3a@newsgroups.borland.com> <pf6qf2d54g6cq331ifq5bvrph2jrdhguiv@4ax.com> <44fd4773$1@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: "Ed Mulroy" <dont_email_me@bitbuc.ket>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <44fc9f3a@newsgroups.borland.com> <pf6qf2d54g6cq331ifq5bvrph2jrdhguiv@4ax.com> <44fd4773$1@newsgroups.borland.com>
Subject: Re: Establishing a Keyboard Hook.........
Date: Tue, 5 Sep 2006 07:31:30 -0400
Lines: 58
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2869
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2962
X-RFC2646: Format=Flowed; Response
NNTP-Posting-Host: 69.242.35.97
Message-ID: <44fd6016$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1157455894 69.242.35.97 (5 Sep 2006 04:31:34 -0700)
X-Authenticated-User: edmulroy
Path: arc1-ca.pugleaf.net!g2news2.google.com!news3.google.com!news4.google.com!news.glorb.com!tudelft.nl!txtfeed1.tudelft.nl!feeder.news-service.com!newsfeed.freenet.de!news.code-werk.net!open-news-network.org!news.soft-gems.net!reader.uucp.at!feeder02.uucp.at!newsfeed.uucp.at!news.uucp.at!newsgroups.borland.com!not-for-mail