.netshutdownsleep-modehibernate-mode

How to programmatically bring a laptop into Sleep mode


What API or tools can I use to query the capabilities of the system and choose the most appropriate on for putting the PC to Sleep, Hibernate or shutdown mode?


Solution

  • Look at SystemInformation.PowerStatus, then you can call Application.SetSuspendState to put the PC to Sleep or Hibernate like:

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