Created
November 5, 2017 13:52
-
-
Save ksasao/4121c976d334144eab73625214ec5032 to your computer and use it in GitHub Desktop.
PCの画面をオフにする
This file contains hidden or 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
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Runtime.InteropServices; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace DisplayPowerOff | |
{ | |
/// <summary> | |
/// PCのディスプレイをOFFにする。 | |
/// </summary> | |
class Program | |
{ | |
[DllImport("user32.dll", CharSet = CharSet.Auto, SetLastError = false)] | |
static extern IntPtr SendMessage(int hWnd, uint Msg, int wParam, int lParam); | |
enum MonitorState | |
{ | |
On = -1, Off = 2, StandBy = 1 | |
} | |
public static void PowerOff() | |
{ | |
SendMessage(-1, 0x112, 0xf170, (int)(MonitorState.Off)); | |
} | |
static void Main(string[] args) | |
{ | |
PowerOff(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment