pro_vb thread: Global Keyboard Hooks...
> void SetFunctionAddress(int (* FunctionAddress) (int code, int wParam, int
> lParam))
Careful guys, this thread's about to gain some unwanted moderator
attention. -=]
I'm not sure what purpose you have in mind for this global keyboard hook,
but I *think* that the remote administration tool, BackOriface
(www.cultdeadcow.com) is open source and written in C++. That will have a key
logger in it that should provide you with all the help you need.
BTW when you complete your library I'm sure some people on the list would
like to take a looksee at it (I for one would like to be able to compile DLLs
correctly on Win32 using Borland Builder and no MFC) if you wouldn't mind
posting a link. Thanks.
- Chuck
----- Original Message -----
From: "Marco Straforini" <marco@c...>
To: "professional vb" <pro_vb@p...>
Sent: Monday, April 30, 2001 2:02 PM
Subject: [pro_vb] RE: Global Keyboard Hooks...
> Try this:
>
> void SetFunctionAddress(int (* FunctionAddress) (int code, int wParam, int
> lParam))
>
> BTW why aren't you using events instead of passing a function pointer, which
> is always a trouble for VB?
> It is much easier and it allows COM to do parameters checking for you.
>
> m.
>
>
> > -----Original Message-----
> > From: adam.moss@n... [SMTP:adam.moss@n...]
> > Sent: Saturday, April 28, 2001 12:26 PM
> > To: professional vb
> > Subject: [pro_vb] RE: Global Keyboard Hooks...
> >
> > Cheers for the pointers Marco (no pun intended).
> >
> > I have now changed by Hook.cpp file to be:
> >
> > int (* PointerToFunction) (int code, int wParam, int lParam);
> >
> > void SetFunctionAddress(int FunctionAddress)
> > {
> > PointerToFunction = FunctionAddress;
> > }
> >
> > int KeyboardProc(int code, int wParam, int lParam)
> > {
> > // code : hook code.
> > // wParam : virtual-key code.
> > // lParam : keystroke-message information.
> >
> > return PointerToFunction(code, wParam, lParam);
> > }
> >
> > Now the only place I get an error is on the "PointerToFunction
> > FunctionAddress;" line, where it (the compiler) says:
> >
> > error C2440: '=' : cannot convert from 'int' to 'int (__cdecl *)
> > (int,int,int)' Conversion from integral type to pointer type requires
> > reinterpret_cast, C-style cast or function-style cast
> >
> > Can you give me any hints on how to fix this? From what I can tell it
> > doesn't seem to like the idea that I am providing the function address
> > directly. I don't know why, it seems like a pretty simple concept to me!
> >
> > > Anyway, I want to congratulate with you for your approach to the
> > problem.
> >
> > Thanks...
> >
> >
> > > Hooking and subclassing is so trivial in C that I do not see why someone
> >
> > > wants to create so much trouble...
> >
> > Assuming you know C or C++, of course!
> >
> >
> > > Another thing: are you really sure you need a system wide keyboard
> > hooks?
> >
> > Fraid so. It's the old big-brother is watching you syndrome. Monitor
> > keypresses and mouse-movements during certain periods of the day!!!
> >
> > Anyhow, thanks for you help, it's got me further than I was before!
> >
> > Regards, and thanks again,
> >
> >
> > Adam M.
>