Tuesday, July 12, 2011

Shutdown, Restart and LogOff windows using C#

using System;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Runtime.InteropServices;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e) { }
[DllImport("user32.dll")]
public static extern int ExitEx(int operationFlag, int operationReason);
protected void btnRestart_Click(object sender, EventArgs e)
{ ExitEx(2, 0); }
protected void btnLogOff_Click(object sender, EventArgs e)
{ ExitWindowsEx(0, 0); }
protected void btnShutDown_Click(object sender, EventArgs e)
{ ExitEx(1, 0); }
}

No comments:

Post a Comment