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); }
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);
}
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
); //打开显示器