diff options
author | sr55 <[email protected]> | 2010-07-09 19:15:08 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2010-07-09 19:15:08 +0000 |
commit | 17392beaf07e263536d58ff96079bdf97d6469e6 (patch) | |
tree | 452ae9da4c785232139462e597cf3ddece62df20 /win/C#/Functions/Win32.cs | |
parent | 52d146b4f937d3358716baeb3eb5ef703dd4c7e0 (diff) |
WinGui:
- Added a new preference that allows the user to prevent the system from going to sleep during an encode.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@3431 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Functions/Win32.cs')
-rw-r--r-- | win/C#/Functions/Win32.cs | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/win/C#/Functions/Win32.cs b/win/C#/Functions/Win32.cs index 89a0c29bb..a50102688 100644 --- a/win/C#/Functions/Win32.cs +++ b/win/C#/Functions/Win32.cs @@ -139,5 +139,32 @@ namespace Handbrake.Functions /// </summary>
CTRL_CLOSE = 2,
}
+
+ [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
+ static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);
+
+ [FlagsAttribute]
+ public enum EXECUTION_STATE : uint
+ {
+ ES_SYSTEM_REQUIRED = 0x00000001,
+ ES_CONTINUOUS = 0x80000000,
+ ES_AWAYMODE_REQUIRED = 0x00000040
+ }
+
+ /// <summary>
+ /// Prevent the system from sleeping
+ /// </summary>
+ public static void PreventSleep()
+ {
+ SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_AWAYMODE_REQUIRED);
+ }
+
+ /// <summary>
+ /// Allow the system to sleep.
+ /// </summary>
+ public static void AllowSleep()
+ {
+ SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
+ }
}
}
|