求关闭笔记本显示器的代码
如题
------解决方案--------------------合上盖子,呵呵,代码都不用了
------解决方案--------------------using System.Runtime.InteropServices;
[DllImport( "User32.DLL ")]
public static extern int SendMessage(IntPtr hWnd,
uint Msg, int wParam, int lParam);
public const int WM_SYSCOMMAND = 0x0112;
public const int SC_MONITORPOWER = 61808;
private void button1_Click(object sender, EventArgs e)
{
SendMessage(Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 1);
}
------解决方案--------------------[DllImport( "user32.dll " )]
public static extern IntPtr SendMessage (
IntPtr hWnd,
uint msg,
uint wParam,
int lParam );
private const uint WM_SYSCOMMAND = 0x0112;
private const uint SC_MONITORPOWER = 0xF170;
调用方法
SendMessage(
this.Handle,
WM_SYSCOMMAND,
SC_MONITORPOWER,
2
); //关闭显示器
SendMessage(
this.Handle,
WM_SYSCOMMAND,
SC_MONITORPOWER,
-1
); //打开显示器