views:

60

answers:

3

I created an application to receive a broadcasted windows message which works fine. When I turn it into a service, install it, and start the service, the service doesn't receive the message.

+1  A: 

The service probably must be granted access to the desktop. Do this from the Service properties, "Log On" tab, Log on as Local System account, and check "Allow service to interact with desktop".

Simon Chadwick
It should be noted that the interact with desktop setting is a bit of a security issue and you should really try to stay away from it.
Anders
+1  A: 

Having windows that run as SYSTEM on a user desktop is a security issue, you should really use some other form of IPC (If all you need to do is notify the service without providing any other data, a (global) named event should be enough)

If on the other hand you want to catch notifications from windows itself about device changes, power and session events etc you don't do that with messages when you are running as a service, you get those events in your HandlerEx

Anders
A: 

Who's sending the broadcast? Unless the component sending the broadcast is running as Local System, it does not have the privilege to send window messages to window handles in different sessions.

Since all Windows Services (since Vista) run in Session 0, and almost all other components run in Session >=1, most probably that's why you are not receiving the broadcast.

Alienfluid