Harus import:
using System.Runtime.InteropServices;
Lock Computer:
[DllImport(“user32.dll”)]
public static extern void LockWorkStation();
Kemudian panggil fungsinya:
LockWorkStation();
Logoff:
[DllImport(“user32.dll”)]
public static extern int ExitWindowsEx(int uFlags, int dwReason);
Panggil fungsinya:
Logoff biasa:
ExitWindowsEx(0, 0);
Logoff force:
ExitWindowsEx(4, 0);
Reboot:
ExitWindowsEx(2, 0);
Shutdown:
ExitWindowsEx(1, 0);
Hibernate:
Application.SetSuspendState(PowerState.Hibernate, true, true);
Standby:
Application.SetSuspendState(PowerState.Suspend true, true);
Bagus kan??