/// <summary> /// Returns the current system power state currently in effect. /// </summary> /// <param name="systemStateName">Receives the system power state name</param> /// <param name="systemState">Receives the system power state</param> /// <returns>Win32 error code</returns> public int GetSystemPowerState(StringBuilder systemStateName, out SystemPowerStates systemState) { uint nError = 0; nError = CEGetSystemPowerState(systemStateName, (uint)systemStateName.Capacity, out systemState); return((int)nError); }
/// <summary> /// Sets the system power state to the requested value. /// </summary> /// <param name="systemState">The system power state to set the device to.</param> /// <returns>Win32 error code</returns> /// <remarks>Should be used with extreme care since it may result in an unexpected /// application or system behavior.</remarks> public int SetSystemPowerState(SystemPowerStates systemState) { uint nError = 0; nError = CESetSystemPowerState( IntPtr.Zero, (uint)systemState, 0); return((int)nError); }
private static extern uint CEGetSystemPowerState(StringBuilder Buffer, uint Length, out SystemPowerStates Flags);
/// <summary> /// Returns the current system power state currently in effect. /// </summary> /// <param name="systemStateName">Receives the system power state name</param> /// <param name="systemState">Receives the system power state</param> /// <returns>Win32 error code</returns> public int GetSystemPowerState(StringBuilder systemStateName, out SystemPowerStates systemState) { uint nError = 0; nError = CEGetSystemPowerState(systemStateName, (uint)systemStateName.Capacity, out systemState); return (int)nError; }
/// <summary> /// Sets the system power state to the requested value. /// </summary> /// <param name="systemState">The system power state to set the device to.</param> /// <returns>Win32 error code</returns> /// <remarks>Should be used with extreme care since it may result in an unexpected /// application or system behavior.</remarks> public int SetSystemPowerState(SystemPowerStates systemState) { uint nError = 0; nError = CESetSystemPowerState( IntPtr.Zero, (uint)systemState, 0); return (int)nError; }