PC Review


Reply
Thread Tools Rate Thread

Compiler Errors Using SetWindowsHookEx in C++ Native DLL

 
 
SteveV
Guest
Posts: n/a
 
      9th Mar 2004
I'm trying to create a native c++ dll so that I can hook keyboard
messages and forward them to my compact frame work MessageWindow.

Here's a code snippet from my dll:

VOLUMEHOOK_API bool InitHook(HWND hMsgWnd, HINSTANCE hMod)
{
ghMessageWnd = hMsgWnd;
ghHook = SetWindowsHookEx(WH_KEYBOARD_LL, &LowLevelKeyboardProc,
(HINSTANCE)hMod, 0);

return ghHook != NULL;
}

When I try to compile the project I get the following errors:

error C2065: 'SetWindowsHookEx' : undeclared identifier
error C2440: '=' : cannot convert from 'int' to 'struct HHOOK__ *'

What's really weird is that intellisense shows the function and
parameters when I use the global scope operator like so:

ghHook = ::SetWindowsHookEx(WH_KEYBOARD_LL, &LowLevelKeyboardProc,
(HINSTANCE)hMod, 0);

Unfortunately, in addition to the 2 errors above, this results in the
following additional error:

error C2039: 'SetWindowsHookEx' : is not a member of '`global
namespace''


Any idea what I might be doing wrong?

TIA
Steve
 
Reply With Quote
 
 
 
 
Lloyd Dupont
Guest
Posts: n/a
 
      9th Mar 2004
A quick look at VS.NET hep convince me that SetWindowsHookEx is defined on
the destop but not on the PPC

"SteveV" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I'm trying to create a native c++ dll so that I can hook keyboard
> messages and forward them to my compact frame work MessageWindow.
>
> Here's a code snippet from my dll:
>
> VOLUMEHOOK_API bool InitHook(HWND hMsgWnd, HINSTANCE hMod)
> {
> ghMessageWnd = hMsgWnd;
> ghHook = SetWindowsHookEx(WH_KEYBOARD_LL, &LowLevelKeyboardProc,
> (HINSTANCE)hMod, 0);
>
> return ghHook != NULL;
> }
>
> When I try to compile the project I get the following errors:
>
> error C2065: 'SetWindowsHookEx' : undeclared identifier
> error C2440: '=' : cannot convert from 'int' to 'struct HHOOK__ *'
>
> What's really weird is that intellisense shows the function and
> parameters when I use the global scope operator like so:
>
> ghHook = ::SetWindowsHookEx(WH_KEYBOARD_LL, &LowLevelKeyboardProc,
> (HINSTANCE)hMod, 0);
>
> Unfortunately, in addition to the 2 errors above, this results in the
> following additional error:
>
> error C2039: 'SetWindowsHookEx' : is not a member of '`global
> namespace''
>
>
> Any idea what I might be doing wrong?
>
> TIA
> Steve



 
Reply With Quote
 
SteveV
Guest
Posts: n/a
 
      9th Mar 2004
You're right, it's not in the docs but apparently it is exported in
coredll and some poeple on this group have had success using it.

I just don't understand why in my case intellisense shows the function
and parameters but it still get compile errors.

Steve

"Lloyd Dupont" <net.galador@ld> wrote in message news:<(E-Mail Removed)>...
> A quick look at VS.NET hep convince me that SetWindowsHookEx is defined on
> the destop but not on the PPC

 
Reply With Quote
 
Paul G. Tobey [eMVP]
Guest
Posts: n/a
 
      9th Mar 2004
It actually is there, but you have to declare it. I've done *exactly* what
you're doing and it works on our Windows CE.NET 4.2-based devices, at least.
I got the declaration from pwinuser.h in Platform Builder. Here's how the
function is declared there:

HHOOK
WINAPI
SetWindowsHookExW(
int idHook,
HOOKPROC lpfn,
HINSTANCE hmod,
DWORD dwThreadId);
#define SetWindowsHookEx SetWindowsHookExW

Paul T.

"SteveV" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> You're right, it's not in the docs but apparently it is exported in
> coredll and some poeple on this group have had success using it.
>
> I just don't understand why in my case intellisense shows the function
> and parameters but it still get compile errors.
>
> Steve
>
> "Lloyd Dupont" <net.galador@ld> wrote in message

news:<(E-Mail Removed)>...
> > A quick look at VS.NET hep convince me that SetWindowsHookEx is defined

on
> > the destop but not on the PPC



 
Reply With Quote
 
SteveV
Guest
Posts: n/a
 
      10th Mar 2004
Thanks, Paul. Works like a charm.

Steve


"Paul G. Tobey [eMVP]" <ptobey_no_spam@instrument_no_spam.com> wrote in message news:<(E-Mail Removed)>...
> It actually is there, but you have to declare it. I've done *exactly* what
> you're doing and it works on our Windows CE.NET 4.2-based devices, at least.
> I got the declaration from pwinuser.h in Platform Builder. Here's how the
> function is declared there:
>
> HHOOK
> WINAPI
> SetWindowsHookExW(
> int idHook,
> HOOKPROC lpfn,
> HINSTANCE hmod,
> DWORD dwThreadId);
> #define SetWindowsHookEx SetWindowsHookExW
>
> Paul T.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
native compiler (dotnet to native code, executeable without .netframework) Michael Reichenbach Microsoft Dot NET 2 25th May 2007 06:12 PM
CLR Native Compiler crash realexander Microsoft Dot NET 0 20th Mar 2007 07:53 PM
Is there a .NET or C# to native x86 compiler? Andy Chau Microsoft Dot NET Framework 11 2nd Jan 2004 06:45 PM
Is there a .NET or C# to native x86 compiler? Andy Chau Microsoft Dot NET 11 2nd Jan 2004 06:45 PM
Serious bug discovered in VC .NET (2002) compiler. [event_source(native)] and __event methods Microsoft VC .NET 1 10th Jul 2003 02:35 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:01 PM.