using System.Runtime.InteropServices;
using System.Windows.Forms;
namespace Trigger.Actions
{
///
/// Actions dealing with power and energy
///
public class Power
{
#region Properties
#endregion
#region Enums, Structs
#endregion
#region Dll Imports
///
/// Locks the workstation's display. Locking a workstation protects it from unauthorized use.
///
///
/// If the function succeeds, the return value is nonzero. Because the function executes asynchronously, a nonzero return value indicates that the operation has been initiated. It does not indicate whether the workstation has been successfully locked.
/// If the function fails, the return value is zero. To get extended error information, call GetLastError.
///
[DllImport("powrprof.dll", CharSet = CharSet.Unicode, SetLastError = true)]
internal static extern bool LockWorkStation();
#endregion
#region Methods
///
/// Suspends the system by shutting power down and entering a suspend (sleep) state.
///
///
///
/// force has no effect
///
///
public static bool Suspend()
{
return Application.SetSuspendState(PowerState.Suspend, force: false, disableWakeEvent: false);
}
///
/// Suspends the system by shutting power down and entering hibernation (S4).
///
///
///
/// force has no effect
///
///
public static bool Hibernate()
{
return Application.SetSuspendState(PowerState.Hibernate, force: false, disableWakeEvent: false);
}
#endregion
}
}