Lock, Stand By, Hibernate and Log Off your System

using System.Runtime.InteropServices;

//Locking the system
[DllImport("user32.dll")]
public static extern void LockWorkStation();


LockWorkStation();
Application.SetSuspendState(PowerState.Suspend, true, true);

//Making system stand by and hibernation

Application.SetSuspendState(PowerState.Suspend, true, true);
Application.SetSuspendState(PowerState.Hibernate, true, true);

//Log off the user

[DllImport("user32.dll")]
public static extern int ExitWindowsEx(int uFlags, int dwReason);

ExitWindowsEx(0, 0);

Comments

Popular posts from this blog

Convert XElement to DataTable

Enable mouse scroll-wheel in VB6

C# code to Check IE Proxy Settings