【C#每日一帖】【響應節能號召】關閉顯示器

利用C#編程,關閉顯示器,在VS2005 +Windows XP下測試成功!編程

#region 關閉顯示器
        public const uint WM_SYSCOMMAND = 0x0112;
        public const uint SC_MONITORPOWER = 0xF170;
        [System.Runtime.InteropServices.DllImport("user32")]
        public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, uint wParam, int lParam);
        public void CloseLCD(object sender, EventArgs e)
        {
            SendMessage(this.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2);    // 2 爲關閉顯示器, -1則打開顯示器 
        }
        #endregion
// 調用關閉顯示器命令        
private void btnCloseDisplayer_Click(object sender, EventArgs e)
        {
            CloseLCD(sender, e);//關閉顯示器
        }
相關文章
相關標籤/搜索