LithMaster
LithMaster

Reputation:

Make multiple monitors go to sleep with Windows API?

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.

Upvotes: 1

Views: 1674

Answers (2)

Rob Walker
Rob Walker

Reputation: 47452

Check out the SC_MONITORPOWER option to the WM_SYSCOMMAND message.

There is a CodeProject example for C#.

Upvotes: 0

stuartd
stuartd

Reputation: 73243

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 C# or VB.NET, there are plenty of samples about demonstrating how to call this from those languages.

Upvotes: 3

Related Questions