I wrote a Windows service that should turn off the display when certain conditions occur. The code I'm using is:
private const int MONITOR_OFF = 2;
SendMessage(GetDesktopWindow().ToInt32(),
WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
The same code works from a Windows application, but nothing happens when a Windows service is executed. There are also no exceptions, and Marshal.GetLastWin32Error()also returns 0.
Any ideas on what I might lose?
source
share