using System;

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

namespace BackLightON
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        [DllImport("coredll.dll", SetLastError = true)]
        private static extern IntPtr SetPowerRequirement(
        string pvDevice,
        CEDEVICE_POWER_STATE DeviceState,
        uint DeviceFlags,
        IntPtr pvSystemState,
        uint StateFlags);

        [DllImport("coredll.dll", SetLastError = true)]
        public static extern uint ReleasePowerRequirement(
           IntPtr hPowerReq
        ); 


        public enum CEDEVICE_POWER_STATE
        {
            PwrDeviceUnspecified = -1,
            D0 = 0,
            D1,
            D2,
            D3,
            D4,
            PwrDeviceMaximum
        }

        IntPtr _backlight = IntPtr.Zero;

        private void button1_Click(object sender, EventArgs e)
        {
            _backlight = SetPowerRequirement("BKL1:", CEDEVICE_POWER_STATE.D0, 1, IntPtr.Zero, 0); 
        }

        private void button2_Click(object sender, EventArgs e)
        {
            ReleasePowerRequirement(_backlight); 
        } 
    }
}