-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathScreenOff
26 lines (18 loc) · 872 Bytes
/
ScreenOff
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#include <windows.h>
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
// Eliminate user's interaction for 500 ms
//Sleep (500);
// Turn off monitor
SendMessage (HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM)2);
// Turn on monitor
// SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) -1);
// Low power monitor
// SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 1);
return 0;
}
//Weird thing is the program keeps running in the background even without loop , aha .
//Don't use main() , or the linker will complain !
//Like this
//1>MSVCRT.lib(exe_winmain.obj) : error LNK2001: unresolved external symbol _WinMain@16
//1>c:\users\ff-ssd\documents\visual studio 2015\Projects\ScreenOff\Release\ScreenOff.exe : fatal error LNK1120: 1 unresolved externals