Introduction
The Monitor power is handled by sending the right message to the Operating System. The code may change depending on the Operating System. This code only works with the Windows Operating System.
Interpo Service
- using System.Runtime.InteropServices
- private const int HWND_BROADCAST = 0xFFFF;//the message is sent to all
- //top-level windows in the system
- private const int SC_MONITORPOWER = 0xF170;
- private const int WM_SYSCOMMAND = 0x112;
SC_MONITORPOWER is a command sent using the WM_SYSCOMMAND message to control the monitor's power.
Monitor State
- private const int MONITOR_ON = -1;
- private const int MONITOR_OFF = 2;
- private const int MONITOR_STANBY = 1;
-1 (the display is power ng on)
1 (the display is going to low power)
2 (the display is being shut off)
The preceding code sets the state of the monitor.
Using the DllImport Attribute
Now use the DllImport Attribute like the following:
- [DllImport("user32.dll")]
SendMessage function
- private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);
Now call the SendMessage function in the Main class.
- SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, MONITOR_OFF);
Various types of SendMessage functions exist, so use all the functions and have fun.
Reference

Arul RPosted Jan 11, 2016, 8:21 AM
Nice share
Santhakumar MunuswamyPosted Jul 30, 2015, 10:58 AM
Nice article. Thanks for sharing
Sibeesh VenuPosted Jul 30, 2015, 5:04 AM
Nice Share
Nilesh JadavPosted Jul 30, 2015, 12:05 AM
Nice one sir
Pankaj Kumar ChoudharyPosted Jul 29, 2015, 1:47 PM
Nice Start........
Gopi ChandPosted Jul 29, 2015, 11:49 AM
Nice one
Rajeesh MenothPosted Jul 29, 2015, 11:21 AM
Good Article
Neeraj KumarPosted Jul 29, 2015, 11:05 AM
Good one