We always used our computer system program to shutdown, log-off, and restart our pc. But here in C#.net we can also do that.
Explanation:- Download
s stands for shutdown
r stands for restart
l stands for log off
t stands for countdown time
When you click Button1 it will shutdown your PC.
When you click Button2 it will log off your PC.
When you click Button3 it will restart your PC.
Code:-
using System;
using
System.Windows.Forms;
using System.Diagnostics;
using
System.Runtime.InteropServices;
namespace ShutDownWindow
{
public partial
class Form1
: Form
{
public Form1()
{
InitializeComponent();
}
//Shut down
private void
button1_Click(object sender, EventArgs e)
{
Process.Start("shutdown", "/s
/t 0");
this.Close();
}
//Log off
private void
button2_Click(object sender, EventArgs e)
{
Process.Start("shutdown", "-l
");
this.Close();
}
//Restart
private void
button3_Click(object sender, EventArgs e)
{
Process.Start("shutdown", "/r
/t 0");
this.Close();
}
//Close
private void
button4_Click(object sender, EventArgs e)
{
this.Close();
}
}
}
Download application for free click here
No comments:
Post a Comment