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