Created
August 21, 2014 16:22
-
-
Save jglozano/c0f3126c2e42537fe0e0 to your computer and use it in GitHub Desktop.
Turn off displays
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static class Display { | |
private const uint WmSyscommand = 0x0112; | |
private const int ScMonitorpower = 0xF170; | |
private const int HwndBroadcast = 0xFFFF; | |
private const int ShutOffDisplay = 2; | |
[DllImport("user32.dll", SetLastError = true)] | |
private static extern bool PostMessage(IntPtr hWnd, uint msg, IntPtr wParam, IntPtr lParam); | |
public static void TurnOff() { | |
PostMessage((IntPtr)HwndBroadcast, WmSyscommand, (IntPtr)ScMonitorpower, (IntPtr)ShutOffDisplay); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment