How to use C # To turn off the monitor)

Source: Internet
Author: User

In response to national saving calls,

Contribute a little bit of power to the country,

I decided,

Turn off the monitor,

It also prolongs the service life of the notebook ..

Of course, on the desktop, directly turn off the display power.

In a notebook, you can only turn off the screen backlight by using the FN shortcut on the keyboard,

The signal output from the motherboard to the screen cannot be switched off. You will still see the dark desktop after careful reading.

I suggest you do not need to wait for your notebook on a regular basis .. It has a great impact on hard disks...

In the "power management" of the desktop display attribute, we can adjust the power supply scheme,

Set the computer to disable the monitor, hard disk, and standby after X minutes. And so on...

 

Command Behavior:

 Powercfg/change "power solution name"/moniter-timeout-ac 1

 

This is troublesome and you need to know the current power supply solution.

 

However, windows provides us with an API. You can immediately disable the monitor.

 

LRESULT WINAPI SendMessage(    __in  HWND hWnd,    __in  UINT Msg,    __in  WPARAM wParam,    __in  LPARAM lParam );

 

See: http://msdn.microsoft.com/en-us/library/ms644950 (VS.85). aspx

 

This API is signed as follows in the platform call:

1 //C# Signature: 2 [DllImport( "user32.dll" , CharSet = CharSet.Auto)] 3 static extern IntPtr SendMessage(IntPtr hWnd, UInt32 Msg, IntPtr wParam, IntPtr lParam);

Each parameter type of this method has some heavy loads. IntPtr is recommended. Otherwise, the 64-bit platform OR other situations may crash ~

 

We need to send Msg a system message, that is, WM_SYSCOMMAND

Then there is additional information, such as Screen Protection: SC _SCREENSAVE, monitor power: SC _MONITORPOWER

WM_SYSCOMMAND has the following values:

enum SysCommands : int {       SC_SIZE     = 0xF000,       SC_MOVE     = 0xF010,       SC_MINIMIZE     = 0xF020,       SC_MAXIMIZE     = 0xF030,       SC_NEXTWINDOW   = 0xF040,       SC_PREVWINDOW   = 0xF050,       SC_CLOSE    = 0xF060,       SC_VSCROLL      = 0xF070,       SC_HSCROLL      = 0xF080,       SC_MOUSEMENU    = 0xF090,       SC_KEYMENU      = 0xF100,       SC_ARRANGE      = 0xF110,       SC_RESTORE      = 0xF120,

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.