شما میتونی از کد زیر استاده کنی :
Process.Start("shutdown","/s /t 0");
اگه خواستی سیستمتو lock کنی و بعد خاموش از کد زیر استفاده کن :
private const int WmSyscommand = 0x0112;
private const int ScMonitorpower = 0xF170;
private const int HwndBroadcast = 0xFFFF;
private const int ShutOffDisplay = 2;
[DllImport("user32.dll")]
private static extern void LockWorkStation();
[DllImport("user32.dll", SetLastError = true)]
private static extern bool PostMessage(IntPtr hWnd, uint msg,
IntPtr wParam, IntPtr lParam);
private static void TurnOffDisplay()
{
PostMessage((IntPtr)HwndBroadcast, (uint)WmSyscommand,
(IntPtr)ScMonitorpower, (IntPtr)ShutOffDisplay);
}
بعد به این شکل صداشون میزنیم :
[STAThread]
static void Main()
{
LockWorkStation();
TurnOffDisplay();
}