> Will Application.Run() work within a service? (e.g. will the message pump
> be
[quoted text clipped - 6 lines]
>
> Simon
There is no UI, it's trying to pick up ALL the keydown events from the
WinAPI via: SetWindowsHookEx in user32.dll.
The application's aim is to just disable the keyboard.
For the API call to work it needs an Application.Run() somewhere to get the
windows message pump running.
In my console app I spawn a thread to hook up the events and then call
Application.Run() that works fine. However, now i've converted it into a
service it no longer works.
Wah.
Any ideas?
> Simon,
>
[quoted text clipped - 12 lines]
> >
> > Simon
Willy Denoyette [MVP] - 19 Nov 2006 15:12 GMT
> There is no UI, it's trying to pick up ALL the keydown events from the
> WinAPI via: SetWindowsHookEx in user32.dll.
[quoted text clipped - 27 lines]
>> >
>> > Simon
Willy Denoyette [MVP] - 19 Nov 2006 15:30 GMT
> There is no UI, it's trying to pick up ALL the keydown events from the
> WinAPI via: SetWindowsHookEx in user32.dll.
[quoted text clipped - 8 lines]
>
> Any ideas?
You are trying to read/process "windows messages", so you effectively have a User Interface.
This is not possible because the service runs in the context of a non-interactive
desktop/winsta,. For a service to run in the same context as an interactive user, you'll
have to set the "interact with desktop" which requires the service to run in the
"localsystem" account. Note that you should only enable this for debugging purposes, and
it's something which won't work on Vista anyway.
Willy.
Simon Tamman - 20 Nov 2006 01:04 GMT
Thank you very much for your help!
Sure enough setting that checkbox to true allows it to run and receive the
events correctly.
Why should this method of operation be only advisable for debugging, is
there a problem with using it in production?
Kind Regards
Simon
> > There is no UI, it's trying to pick up ALL the keydown events from the
> > WinAPI via: SetWindowsHookEx in user32.dll.
[quoted text clipped - 17 lines]
>
> Willy.