2 This file is part of the HandBrake source code.
\r
3 Homepage: <http://handbrake.fr>.
\r
4 It may be used under the terms of the GNU General Public License. */
\r
6 namespace Handbrake.Functions
\r
9 using System.Runtime.InteropServices;
\r
17 /// Set the Forground Window
\r
19 /// <param name="hWnd">
\r
23 /// A Boolean true when complete.
\r
25 [DllImport("user32.dll")]
\r
26 public static extern bool SetForegroundWindow(int hWnd);
\r
29 /// Lock the workstation
\r
31 [DllImport("user32.dll")]
\r
32 public static extern void LockWorkStation();
\r
37 /// <param name="uFlags">
\r
40 /// <param name="dwReason">
\r
46 [DllImport("user32.dll")]
\r
47 public static extern int ExitWindowsEx(int uFlags, int dwReason);
\r
50 /// System Memory Status
\r
52 public struct MEMORYSTATUS // Unused var's are required here.
\r
57 public UInt32 dwLength;
\r
62 public UInt32 dwMemoryLoad;
\r
65 /// Total Physical Memory
\r
67 public UInt32 dwTotalPhys; // Used
\r
70 /// Available Physical Memory
\r
72 public UInt32 dwAvailPhys;
\r
77 public UInt32 dwTotalPageFile;
\r
80 /// Available Page File
\r
82 public UInt32 dwAvailPageFile;
\r
85 /// Total Virtual Memory
\r
87 public UInt32 dwTotalVirtual;
\r
90 /// Available Virtual Memory
\r
92 public UInt32 dwAvailVirtual;
\r
96 /// Global Memory Status
\r
98 /// <param name="lpBuffer">
\r
101 [DllImport("kernel32.dll")]
\r
102 public static extern void GlobalMemoryStatus
\r
104 ref MEMORYSTATUS lpBuffer
\r
108 /// Generate a Console Ctrl Event
\r
110 /// <param name="sigevent">
\r
113 /// <param name="dwProcessGroupId">
\r
114 /// The dw process group id.
\r
117 /// Bool true is sucess
\r
119 [DllImport("kernel32.dll", SetLastError = true)]
\r
120 public static extern bool GenerateConsoleCtrlEvent(ConsoleCtrlEvent sigevent, int dwProcessGroupId);
\r
123 /// Console Ctrl Event
\r
125 public enum ConsoleCtrlEvent
\r
143 [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]
\r
144 static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);
\r
147 public enum EXECUTION_STATE : uint
\r
149 ES_SYSTEM_REQUIRED = 0x00000001,
\r
150 ES_CONTINUOUS = 0x80000000,
\r
151 ES_AWAYMODE_REQUIRED = 0x00000040
\r
155 /// Prevent the system from sleeping
\r
157 public static void PreventSleep()
\r
159 SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_AWAYMODE_REQUIRED);
\r
163 /// Allow the system to sleep.
\r
165 public static void AllowSleep()
\r
167 SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);
\r