C# 关闭显示器的函数

最近在学C#,写个保护眼睛的程序(就是过一段时间关下显示器,锁下屏幕之类的)做为练习。以下是关闭显示器的代码,网上好像还没有,在这贴上来,希望对大家有帮助。
 1ExpandedBlockStart.gifContractedBlock.gif/**//// <summary>
 2InBlock.gif        /// 关闭显示器
 3InBlock.gif        /// </summary>
 4InBlock.gif        /// <param name="sender"></param>
 5ExpandedBlockEnd.gif        /// <param name="e"></param>

 6None.gif        void CloseLCD(object sender, EventArgs e)
 7ExpandedBlockStart.gifContractedBlock.gif        dot.gif{
 8InBlock.gif            SendMessage(this.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2);    // 2 为关闭显示器, -1则打开显示器
 9ExpandedBlockEnd.gif        }

10ContractedBlock.gifExpandedBlockStart.gif        SendMessage#region SendMessage
11InBlock.gif        public const uint WM_SYSCOMMAND = 0x0112;
12InBlock.gif        public const uint SC_MONITORPOWER = 0xF170;
13InBlock.gif        [DllImport("user32")]
14InBlock.gif        public static extern IntPtr SendMessage(IntPtr hWnd, uint wMsg, uint wParam, int lParam);
15ExpandedBlockEnd.gif        #endregion
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值