Link to home
Start Free TrialLog in
Avatar of cvmilitaru
cvmilitaru

asked on

About hooks and NT services.

How can I install a keyboard hook in a NT service?
Avatar of BudVVeezer
BudVVeezer

Ok, I could be WAY off, but if I am thinking correctly,. it's not possible to install a keyboard hook, or mouse hook, or any hook on an NT service.  My reasoning is this, it's all over a network, with multiple people using the same program.  Your hook would quickly get consfused with all of the input coming in from different directions...  To ease this, I think Microsoft decided to not allow you to install hooks.  I'm not posting this as an answer yet, but after I do some checking, I might have to come back....  What is it you're trying to accomplish?  Maybe there's a work around.

~Aaron
ok, i seem to be way off.  you can implement a keyboard hook in NT.  =)  What are you having troubles with?  I have code to install the hook...

~Aaron
u can find this code in online MSDN .

search for win32 hooks and will reach the sample code for the same .

save those files and run the sample .

i have tried it ..it works fine .

regards
Avatar of cvmilitaru

ASKER

For BudWeezer and Aggarwal:
I have already done a keyboard proc in a dll for installing in the hook chain. If I load it from a normal application, it works.
 
When I try to load my function from a NT service all seems to be ok, there is none error messege, but the hooks doesn't work.

My questions is what is happen ?
Why the function doesn't work, even if I dont't receive any error messege?

Regards
can u please post the code !!!
part of it could be with my earlier statement of apps running the hook at the same time.  When you debug it, does the hook even get initialized?  Post code por favor.  =)

~Aaron
NT Services allow you to interact from the desktop; set the service's profile to Allow Interaction with the Desktop. There is one problem, though, if you allow desktop interaction, you cannot access the network from the service. One or the other, you choose.
syscyk, your comment is OK. Send it as an answer. And thanks.
cvmilitaru
ASKER CERTIFIED SOLUTION
Avatar of syscyk
syscyk

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello, is anyone out there!  I also have run into some problems in NT with the WH_GETMESSAGE hook.  It allows me to look at the message, but I cannot modify it like you normally can outside of NT.  Even more puzzling than that, it only seems to happen when hooking MSWord.  Points being offerred!!
This question was awarded, but never cleared due to the JSP-500 errors of that time.  It was "stuck" against userID -1 versus the intended expert whom you awarded.  This corrects that and the expert will now receive these points, all verified.
Moondancer
Moderator @ Experts Exchange