0

My application (running as system service) has a feature where the display "blinks" a few times for some reason. This is done through a special API that allows access to the backlight control. This works so far. But when the display turns off because of the "Turn off display" setting in the power options, it seems that nothing hapeens (from user view).

Looking for a solution always ended up in suggestions to use SendMessage, SendNotifyMessage or SetThreadExectionState. These function doesn't work from called from a system service (at least in Windows Vista and later).

I'm quite sure there are ways to turn display on even if there no chance to do that in the user's context because no user is logged on. However, I could not find out, how to. I hope you can help me.

P.S.: I tried with an (helper) application in user mode and could see that it works even if the worksatation is locaked (Win+L). The only problem that remains is that I cannot turn on the display when running as service and no user is logged on.

Willy K.
  • 397
  • 2
  • 14
  • 1
    A service can create a process with CreateProcessAsUser (https://msdn.microsoft.com/en-us/library/windows/desktop/ms682429%28v=vs.85%29.aspx). I suppose this process could then use power management API under the control of your service to force the display on when needed. – kuroi neko Feb 19 '16 at 15:30
  • Thanks for your inpuit. I already have such a "helper" applicatoin that interacts with the service. I edited my post just before and could see that it will work this way - the remaining "problematic" situation that can occour is when dipslay blanks while no user is logged on. – Willy K. Feb 19 '16 at 16:41
  • I suppose you could use a trigger (https://technet.microsoft.com/en-us/library/cc748841.aspx) to launch a helper .exe at startup. Not sure if it would be allowed to mess with power management though... – kuroi neko Feb 19 '16 at 17:13
  • My "helper" will be started when a user logs on, triggered by the SERVICE_CONTROL_SESSIONCHANGE in the ServeiceHandlerEx() function. Remember that I am looking for a way to turn on display if no user is logged in. – Willy K. Feb 19 '16 at 18:08
  • There is still a session with control of the display, and I believe always a process running in it (to display the logon dialog on request). Not sure how you would best go about locating the right process, but you may be able to work something out. – Harry Johnston Feb 19 '16 at 23:57

0 Answers0