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;
2、调用方法
SendMessage( this.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2 ); //关闭显示器 SendMessage( this.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, -1 ); //打开显示器