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 PowerState
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            #if DEBUG
                MinimizeBox = false;
            #else
                MinimizeBox = true;
            #endif
        }

        [DllImport("coredll.dll", SetLastError = true)]
        static extern int SetSystemPowerState(string psState, int StateFlags, int Options);

        public const int POWER_STATE_ON = 0x00010000; // on state
        public const int POWER_STATE_IDLE = 0x00100000;  // idle state
        public const int POWER_STATE_OFF = 0x00020000; // no power, full off
        public const int POWER_STATE_CRITICAL = 0x00040000; // critical off
        public const int POWER_STATE_BOOT = 0x00080000; // boot state
        public const int POWER_STATE_SUSPEND = 0x00200000; // suspend state
        public const int POWER_STATE_RESET = 0x00800000; // reset state 

        public const int POWER_NAME = 0x00000001; // по умолчанию
        public const int    POWER_FORCE = 0x00001000;

        private void butTurnOff_Click(object sender, EventArgs e)
        {
            SetSystemPowerState(null, POWER_STATE_IDLE, POWER_NAME);
        }

        private void butTurnOn_Click(object sender, EventArgs e)
        {
            SetSystemPowerState(null, POWER_STATE_ON, POWER_NAME);
        }
     }
}