On Off Switch

Image Source: http://thumbs.dreamstime.com/thumb_76/1154983417etR5O8.jpg

Nowadays, I’m experimenting with some hardware and Windows :).I’m very happy to work with this. Because, after a lot of reading and googling, doing some coding. Then again, reading a lot of documents 🙂

A very interesting thing in doing this type of coding is that, we don’t get  much information from MSDN :D. Almost all information is available in the MSDN, but it’s up to you to find the best algorithm/class/technology that fit for you.

Yesterday, I tried a lot to get the information from our Desktop Monitor. My aim was to ON/OFF our Desktop Monitor. I have hands on experience with WMI (Windows Management Instrumentation) to query the details like motherboard, disks, Operating System etc. With that confidence I first look into the Win32_DesktopMonitor. And in that a method named SetPowerState() is available. And the information about that method give me immense pleasure.

Its like “The SetPowerState method sets the desired power state for a logical device and when a device should be put into that state. And the power state may have the following values, like(from MSDN)

1 Full power.
2 Power save — low-power mode.
3 Power save — standby.
4 Power save — other.
5 Power cycle.
6 Power off.

I’m very happy after reading this document.  Unfortunately, its not implemented by windows. Due to a lot of technical problems.


But using the very common message like SendMessage can solve the problem so easily.

Just copy the below statement and execute..


Hope you are familiar with first 2 params. Documentation from the  MSDN for the 3rd param is

SC_MONITORPOWER Sets the state of the display. This command supports devices that have power-saving features, such as a battery-powered personal computer.

And the 4th param may take the values like

-1 – the display is being on

1 – the display is going to low power

2 – the display is being shut off

I think it is so simple. Thanks to Microsoft.. 🙂

for https://vctipsplusplus.wordpress.com/


God won’t ask about the fancy clothes in your wardrobe, but will ask how many of those clothes helped the needy.