如果麦克风上的噪音在一段时间内过高,我看到有关Linux屏幕消隐的问题。 提问者想要使用它,以便孩子们在玩游戏时保持安静。 Linux Blank Screen
如何在Windows上使用C#完成相同的任务?
答案 0 :(得分:2)
这是关闭屏幕的方法:
using System.Runtime.InteropServices; //to DllImport
public int WM_SYSCOMMAND = 0x0112;
public int SC_MONITORPOWER = 0xF170; //Using the system pre-defined MSDN constants that can be used by the SendMessage() function .
[DllImport("user32.dll")]
private static extern int SendMessage(int hWnd, int hMsg, int wParam, int lParam);
//To call a DLL function from C#, you must provide this declaration .
private void button1_Click(object sender, System.EventArgs e)
{
SendMessage( this.Handle.ToInt32() , WM_SYSCOMMAND , SC_MONITORPOWER ,2 );//DLL function
}