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?
Thanks for any pointers.
2. The Alt + F4 Sleep Mode Shortcut. As you might know, pressing Alt + F4 closes the current app window, just like clicking the X in the top-right corner of a program. However, if you don't have a window currently selected, you can use Alt + F4 as a shortcut for sleep in Windows 10.
In the BIOS menu, select "Power Management" then "Block Sleep". Take the check mark out of "Block Sleep" then click "Apply". When you reboot, you will have the option to sleep.
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);
You could use the API:
Declare Function SetSuspendState Lib "PowrProf" (ByVal Hibernate As Integer, ByVal ForceCritical As Integer, ByVal DisableWakeEvent As Integer) As Integer
SetSuspendState(0, 0, 0) 'Sleep without forcing and ?no? wake events
SetSuspendState(1, 0, 0) 'Hibernate without forcing and ?no? wake events
Set Hibernate to 1(True) to Hibernate or 0(False) to Sleep.
See the API here.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With