利用C#编程,关闭显示器,在VS2005 +Windows XP下测试成功!
#region 关闭显示器
public const uint WM_SYSCOMMAND = 0x0112;
public const uint SC_MONITORPOWER = 0xF170;
[System.Runtime.InteropServices.DllImport("user32")]
public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, uint wParam, int lParam);
public void CloseLCD(object sender, EventArgs e)
{
SendMessage(this.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2); // 2 为关闭显示器, -1则打开显示器
}
#endregion
// 调用关闭显示器命令
private void btnCloseDisplayer_Click(object sender, EventArgs e)
{
CloseLCD(sender, e);//关闭显示器
}
来源:oschina
链接:https://my.oschina.net/u/138598/blog/28584