Windows lock screen and then turn off the monitor, executable program

Source: Internet
Author: User

Sometimes we need to close the screen to have a rest or write something on Ben, but it's distracting when the screen is on, but it's too much trouble to turn off the monitor, so go straight to a small program (non-applet). There is a situation, sometimes at night to leave the computer next, but the computer is still doing things, do not want to shut down the computer, and because the night is dark, the screen will be scolded, combined with the above situation, this terminal code is very suitable for you.

If you don't compile the code, it's okay, I have the compiled executable file here, download link http://www.yxxrui.cn/article/71.shtml

usingSystem;usingSystem.Collections.Generic;usingSystem.Runtime.InteropServices;usingSystem.Text;namespacelockandclosewindow{classProgram {//System Messages        Private Const UINTWm_syscommand=0x112; //system commands to turn off the monitor        Private Const intSc_monitorpower=0xf170; //2 for Poweroff, 1 for power saving, 1 for boot        Private Const intmonitorpoweroff=2; //broadcast messages, all top-level forms receive        Private Static ReadOnlyIntPtr Wnd_broadcast =NewINTPTR (0xFFFF); Static voidMain (string[] args) {lockworkstation ();//Lock ScreenSystem.Threading.Thread.Sleep (Ten); SendMessage (Hwnd_broadcast, Wm_syscommand, Sc_monitorpower, Monitorpowe            ROFF); //turn off the monitor        }        //Lock Screen[DllImport ("user32.dll")]         Public Static extern BOOLlockworkstation (); //turn off the monitor[DllImport ("user32.dll")]        Private Static externIntPtr SendMessage (IntPtr hWnd,UINTMSG,intWParam,intLParam); }}

Iraqis blog: original link: http://www.yxxrui.cn/article/70.shtml

Windows lock screen and then turn off the monitor, executable program

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.