OSDN Git Service

add win/C# diff files
[handbrake-jp/handbrake-jp.git] / win / C# / HandBrake.ApplicationServices / Functions / Win32.cs.diff
diff --git a/win/C#/HandBrake.ApplicationServices/Functions/Win32.cs.diff b/win/C#/HandBrake.ApplicationServices/Functions/Win32.cs.diff
new file mode 100644 (file)
index 0000000..c481a02
--- /dev/null
@@ -0,0 +1,150 @@
+diff --git a/win/C#/HandBrake.ApplicationServices/Functions/Win32.cs b/win/C#/HandBrake.ApplicationServices/Functions/Win32.cs
+new file mode 100644
+index 0000000..8cb464b
+--- /dev/null
++++ b/win/C#/HandBrake.ApplicationServices/Functions/Win32.cs
+@@ -0,0 +1,144 @@
++/*  win32.cs $\r
++    This file is part of the HandBrake source code.\r
++    Homepage: <http://handbrake.fr>.\r
++    It may be used under the terms of the GNU General Public License. */\r
++\r
++namespace HandBrake.ApplicationServices.Functions\r
++{\r
++    using System;\r
++    using System.Runtime.InteropServices;\r
++\r
++    /// <summary>\r
++    /// Win32 API calls\r
++    /// </summary>\r
++    public class Win32\r
++    {\r
++        /// <summary>\r
++        /// Set the Forground Window\r
++        /// </summary>\r
++        /// <param name="hWnd">\r
++        /// The h wnd.\r
++        /// </param>\r
++        /// <returns>\r
++        /// A Boolean true when complete.\r
++        /// </returns>\r
++        [DllImport("user32.dll")]\r
++        public static extern bool SetForegroundWindow(int hWnd);\r
++\r
++        /// <summary>\r
++        /// Lock the workstation\r
++        /// </summary>\r
++        [DllImport("user32.dll")]\r
++        public static extern void LockWorkStation();\r
++\r
++        /// <summary>\r
++        /// Exit Windows\r
++        /// </summary>\r
++        /// <param name="uFlags">\r
++        /// The u flags.\r
++        /// </param>\r
++        /// <param name="dwReason">\r
++        /// The dw reason.\r
++        /// </param>\r
++        /// <returns>\r
++        /// an integer\r
++        /// </returns>\r
++        [DllImport("user32.dll")]\r
++        public static extern int ExitWindowsEx(int uFlags, int dwReason);\r
++\r
++        /// <summary>\r
++        /// Memory Status EX Struct\r
++        /// </summary>\r
++        public struct MEMORYSTATUSEX\r
++        {\r
++            public int dwLength;\r
++            public int dwMemoryLoad;\r
++            public ulong ullTotalPhys;\r
++            public ulong ullAvailPhys;\r
++            public ulong ullTotalPageFile;\r
++            public ulong ullAvailPageFile;\r
++            public ulong ullTotalVirtual;\r
++            public ulong ullAvailVirtual;\r
++            public ulong ullAvailExtendedVirtual;\r
++        }\r
++\r
++        /// <summary>\r
++        /// Get the System Memory information\r
++        /// </summary>\r
++        /// <param name="lpBuffer">\r
++        /// The lp buffer.\r
++        /// </param>\r
++        /// <returns>\r
++        /// A boolean.\r
++        /// </returns>\r
++        [DllImport("kernel32.dll", SetLastError = true)]\r
++        public static extern bool GlobalMemoryStatusEx(ref MEMORYSTATUSEX lpBuffer);\r
++\r
++\r
++        /// <summary>\r
++        /// Generate a Console Ctrl Event\r
++        /// </summary>\r
++        /// <param name="sigevent">\r
++        /// The sigevent.\r
++        /// </param>\r
++        /// <param name="dwProcessGroupId">\r
++        /// The dw process group id.\r
++        /// </param>\r
++        /// <returns>\r
++        /// Bool true is sucess\r
++        /// </returns>\r
++        [DllImport("kernel32.dll", SetLastError = true)]\r
++        public static extern bool GenerateConsoleCtrlEvent(ConsoleCtrlEvent sigevent, int dwProcessGroupId);\r
++\r
++        /// <summary>\r
++        /// Console Ctrl Event\r
++        /// </summary>\r
++        public enum ConsoleCtrlEvent\r
++        {\r
++            /// <summary>\r
++            /// Ctrl - C\r
++            /// </summary>\r
++            CTRL_C = 0,\r
++\r
++            /// <summary>\r
++            /// Ctrl - Break\r
++            /// </summary>\r
++            CTRL_BREAK = 1,\r
++\r
++            /// <summary>\r
++            /// Ctrl - Close\r
++            /// </summary>\r
++            CTRL_CLOSE = 2,\r
++        }\r
++\r
++        [DllImport("kernel32.dll", CharSet = CharSet.Auto, SetLastError = true)]\r
++        static extern EXECUTION_STATE SetThreadExecutionState(EXECUTION_STATE esFlags);\r
++\r
++        /// <summary>\r
++        /// Execution State\r
++        /// </summary>\r
++        [FlagsAttribute]\r
++        public enum EXECUTION_STATE : uint\r
++        {\r
++            ES_SYSTEM_REQUIRED = 0x00000001,\r
++            ES_CONTINUOUS = 0x80000000,\r
++            ES_AWAYMODE_REQUIRED = 0x00000040\r
++        }\r
++\r
++        /// <summary>\r
++        /// Prevent the system from sleeping\r
++        /// </summary>\r
++        public static void PreventSleep()\r
++        {\r
++            SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS | EXECUTION_STATE.ES_SYSTEM_REQUIRED | EXECUTION_STATE.ES_AWAYMODE_REQUIRED);\r
++        }\r
++\r
++        /// <summary>\r
++        ///  Allow the system to sleep.\r
++        /// </summary>\r
++        public static void AllowSleep()\r
++        {\r
++            SetThreadExecutionState(EXECUTION_STATE.ES_CONTINUOUS);\r
++        }\r
++    }\r
++}\r