views:

290

answers:

2

How exactly would I make both of my monitors go to sleep, I want to write an application myself because I'd like to add certain functionality, and so far I can't find anything on MSDN relating to making your display go to sleep.

+1  A: 

You want something like:

SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2);

It should work on dual monitors.

Although it might be best not to use HWND_BROADCAST, but instead to use a HWND from your app's own window. You don't say what language you're using, but if it's CSharp or VB there are plenty of samples about demonstrating how to call this from those languages.

Stuart Dunkeld
I'm using C++ and it's a console application, I call FreeConsole(); to hide the console as soon at it is executed. The call worked exactly like I wanted it to, but since I have no visible window, do I need to use my own HWND?
A: 

Check out the SC_MONITORPOWER option to WM_SYSCOMMAND

There is a Code Project example from C#

Rob Walker