Skip to content

Instantly share code, notes, and snippets.

@Y-Koji
Created March 17, 2018 09:50
Show Gist options
  • Save Y-Koji/7b8a2b6a049013c0f5419b5363c9dd91 to your computer and use it in GitHub Desktop.
Save Y-Koji/7b8a2b6a049013c0f5419b5363c9dd91 to your computer and use it in GitHub Desktop.
ノートPCのディスプレイ電源を切るプログラム
#include <stdio.h>
#include <windows.h>
#include <winuser.h>
#pragma comment(lib, "user32.lib")
#define DISPLAY_ON (-1)
#define DISPLAY_OFF (2)
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
PostMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, DISPLAY_OFF);
}
@Y-Koji
Copy link
Author

Y-Koji commented Mar 17, 2018

コンパイル済みバイナリは以下
https://www.dropbox.com/s/vmt47gr5eqpj13i/display_off.exe?dl=0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment