关闭显示器-转

来源:互联网 发布:单片机编程技巧 编辑:程序博客网 时间:2024/04/29 08:20

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Runtime.InteropServices;

namespace WindowsFormsApplication3
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public const uint WM_SYSCOMMAND = 0x0112;
        public const uint SC_MONITORPOWER = 0xF170;
        [DllImport("user32")]
        public static extern IntPtr SendMessage(IntPtr hWnd,uint wMsg,uint wParam, int IParam);

        private void button1_Click(object sender, EventArgs e)
        {
            CloseLCD(sender,e);
        }
        void CloseLCD(object sender,EventArgs e)
        {
            SendMessage(this.Handle, WM_SYSCOMMAND, SC_MONITORPOWER, 2);//2为黑屏,-1为打开
        }


       


    }
}

原创粉丝点击