我想用C编写一个非常小的应用程序,可以关闭或打开屏幕。映射键以调用特定函数应该不难。
在Windows上关闭或打开屏幕的系统命令是什么?
由于
答案 0 :(得分:2)
// Turn off monitor
Sleep(500); // Eliminate user's interaction for 500 ms
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2);
// Turn on monitor
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) -1);
// Low power monitor
Sleep(500); // Eliminate user's interaction for 500 ms
SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 1);
请注意
**1** - the display is going to low power.
**2** - the display is being shut off.
**-1** - the display is being turned on (undocumented value).