1
Reply

Shutdown program in c#

Mihaly Varga

Mihaly Varga

Jan 8 2013 12:16 PM
1.6k
I want to write a program, which is shut down, or restart the pc.

In the form, i have a datetimepicker tool, and 2 button. So, my question is, which code can i shut down the pc, and how can i read the selected time from the datetimepicker ( which is set to time ( h/m ) ) ? 





The code is currently:

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

        private void Form1_Load(object sender, EventArgs e)
        {

        }

        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {
            dateTimePicker1.Format = DateTimePickerFormat.Short;
            dateTimePicker1.Value = DateTime.Today;
        }

        private void button1_Click(object sender, EventArgs e)
        {
            DateTime iDate;
            iDate = dateTimePicker1.Value;
            MessageBox.Show("A kiválasztott dátum: " + iDate);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            DateTime iDate;
            iDate = dateTimePicker1.Value;
            MessageBox.Show("A kiválasztott dátum: " + iDate);
        }
    }
}


Answers (1)
Next Recommended Forum