Hi i'm searching a solution to avoid that the user can go in the standby
mode while a app is runing.
i have searched and readed a lot in the web and have not found a working
solution...
for the moment i use "away mode" under vista to get simiar results but with
other handycaps like screen off etc. :-(
i have get this code from a other dev but it doesnt work with vista, the pc
its going directly in the standby mode.
------------------------------------------
using System;
using System.Windows.Forms;
using System.Runtime.InteropServices;
namespace MonitorSleepPrevent
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
[DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
static extern EXECUTION_STATE SetThreadExecutionState(
EXECUTION_STATE flags);
[Flags]
public enum EXECUTION_STATE : uint
{
ES_SYSTEM_REQUIRED = 0x00000001,
ES_DISPLAY_REQUIRED = 0x00000002,
// ES_USER_PRESENT = 0x00000004,
ES_CONTINUOUS = 0x80000000
}
void PreventMonitorPowerdown()
{
SetThreadExecutionState( EXECUTION_STATE.ES_DISPLAY_REQUIRED |
EXECUTION_STATE.ES_CONTINUOUS);
}
void AllowMonitorPowerdown()
{
SetThreadExecutionState(EXECUTION_STATE.ES_CONTINU OUS);
}
private void Form1_Load(object sender, EventArgs e)
{
PreventMonitorPowerdown();
}
}
}
------------------------------------------
please help me to get a working solution for that
what i need is:
if the app is running and the user is pressing the power button (standby) or
uses the start\shutdown(standby) menu the pc should still on.
thank you for any tips
Volkan