在程序中打开/关闭monitor or lcd
hWnd
Handle to the window whose window procedure will receive the message. If you don't want to bother creating a window to send the message to, you can send the message to all top level windows (
HWND_BROADCAST
) or you can useGetDesktopWindow
function sending the message to the desktop window.Msg
Specifies the message to be sent (
WM_SYSCOMMAND
).wParam
Specifies additional message-specific information (
SC_MONITORPOWER
).lParam
- 1 - the display is going to low power.
- 2 - the display is being shut off.
- -1 - the display is being turned on (undocumented value).
// 关闭 monitor Sleep(500); // Eliminate user's interaction for 500 ms SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 2); // 打开 monitor SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) -1); // 电池模式,低电量
Sleep(500); // Eliminate user's interaction for 500 ms SendMessage(HWND_BROADCAST, WM_SYSCOMMAND, SC_MONITORPOWER, (LPARAM) 1);
ref
vc版本: http://www.codeproject.com/KB/system/display_states.aspx
C# 版本: http://www.codeproject.com/KB/cs/Monitor_management_guide.aspx