Listening to windows messages from a windows service

  • Thread starter Thread starter andrewbb
  • Start date Start date
A

andrewbb

I'm developing a windows service that needs to listen for a particular
WM_ message. Is there a way to listen for a message from .NET service
application?

This would seem to be a simple thing, but I haven't seen anything on
it...
 

Yes, thank you, that was it!

Unfortunately I can't get it to work. I created a NativeWindow and
overrode its WndProc. It works great when started with
Application.Run(), but no messages are received when started as a
Service.

Interact with the Desktop is checked.
The window handle is created in the Service.
The call to RegisterHotkey is successful.

But no messages.

As a test I stuck an Application.Run() in the OnStart. Suddenly
messages are received. (it hangs the service of course)


So what's the difference between ServiceBase.Run and Application.Run
in how windows messages are received? It looks like ServiceBase.Run
isn't forwarding the messages to my NativeWindow.

Ideas?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top