首页  编辑  

关闭/打开显示器

Tags: /C#/系统相关/   Date Created:

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 );

}

private void button2_Click( object sender , EventArgs e)

{

   SendMessage(Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 0 );

}