Hi, i have now tryed some combinations and found one working solution, i send this Bavarian too:
Code:
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace PowerApp
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("Kernel32.dll", EntryPoint = "SetThreadExecutionState", CharSet = CharSet.Auto, SetLastError = true)]
private extern static EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE state);
[Flags]
public enum EXECUTION_STATE : uint
{
ES_AWAYMODE_REQUIRED = 0x00000040,
ES_CONTINUOUS = 0x80000000,
ES_DISPLAY_REQUIRED = 0x00000002,
ES_SYSTEM_REQUIRED = 0x00000001,
ES_USER_PRESENT = 0x00000004
}
private void Form1_Load(object sender, EventArgs e)
{
try
{
SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_AWAYMODE_REQUIRED);
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
}
}
}
The only thing is that in the windows power settings should disabled that a password is needed for recovery...
