2013-02-11 42 views
-1

空白屏幕,我看到一個問題,關於Linux的上清屏,如果上的麥克風噪聲走過去的時間長度太高。 提問者想用它使孩子保持安靜,而玩遊戲。 Linux Blank Screen在Windows

如何將相同的任務使用C#在Windows上完成?

回答

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 
}