锁定计算机
//锁定计算机
[DllImportAttribute("user32.dll")] public static extern void LockWorkStation(); 禁止关闭计算机 private const int WM_QUERYENDSESSION = 0x0011;//windows消息 int flag = 0;//标识变量 protected override void WndProc(ref System.Windows.Forms.Message e) { if (e.Msg == WM_QUERYENDSESSION) { e.Result = (IntPtr)flag; } base.WndProc(ref e); } /// <summary> /// 禁止关闭计算机 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void NoShutdown_Click(object sender, EventArgs e) { flag = 0; }