OSDN Git Service

b5ca77c0631fc142f6c43077a23846f1ff970f3d
[handbrake-jp/handbrake-jp-git.git] / win / C# / Functions / Win32.cs
1 /*  win32.cs $\r
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
5 \r
6 \r
7 namespace Handbrake.Functions\r
8 {\r
9     using System;\r
10     using System.Runtime.InteropServices;\r
11 \r
12     /// <summary>\r
13     /// Win32 API calls\r
14     /// </summary>\r
15     public class Win32\r
16     {\r
17         /// <summary>\r
18         /// Set the Forground Window\r
19         /// </summary>\r
20         /// <param name="hWnd">\r
21         /// The h wnd.\r
22         /// </param>\r
23         /// <returns>\r
24         /// A Boolean true when complete.\r
25         /// </returns>\r
26         [DllImport("user32.dll")]\r
27         public static extern bool SetForegroundWindow(int hWnd);\r
28 \r
29         /// <summary>\r
30         /// Lock the workstation\r
31         /// </summary>\r
32         [DllImport("user32.dll")]\r
33         public static extern void LockWorkStation();\r
34 \r
35         /// <summary>\r
36         /// Exit Windows\r
37         /// </summary>\r
38         /// <param name="uFlags">\r
39         /// The u flags.\r
40         /// </param>\r
41         /// <param name="dwReason">\r
42         /// The dw reason.\r
43         /// </param>\r
44         /// <returns>\r
45         /// an integer\r
46         /// </returns>\r
47         [DllImport("user32.dll")]\r
48         public static extern int ExitWindowsEx(int uFlags, int dwReason);\r
49 \r
50         /// <summary>\r
51         /// System Memory Status\r
52         /// </summary>\r
53         public struct MEMORYSTATUS // Unused var's are required here.\r
54         {\r
55             public UInt32 dwLength;\r
56             public UInt32 dwMemoryLoad;\r
57             public UInt32 dwTotalPhys; // Used\r
58             public UInt32 dwAvailPhys;\r
59             public UInt32 dwTotalPageFile;\r
60             public UInt32 dwAvailPageFile;\r
61             public UInt32 dwTotalVirtual;\r
62             public UInt32 dwAvailVirtual;\r
63         }\r
64 \r
65         /// <summary>\r
66         /// Global Memory Status\r
67         /// </summary>\r
68         /// <param name="lpBuffer">\r
69         /// The lp buffer.\r
70         /// </param>\r
71         [DllImport("kernel32.dll")]\r
72         public static extern void GlobalMemoryStatus\r
73         (\r
74             ref MEMORYSTATUS lpBuffer\r
75         );\r
76 \r
77         [DllImport("kernel32.dll", SetLastError = true)]\r
78         public static extern bool GenerateConsoleCtrlEvent(ConsoleCtrlEvent sigevent, int dwProcessGroupId);\r
79 \r
80         /// <summary>\r
81         /// Console Ctrl Event\r
82         /// </summary>\r
83         public enum ConsoleCtrlEvent\r
84         {\r
85             CTRL_C = 0,\r
86             CTRL_BREAK = 1,\r
87             CTRL_CLOSE = 2,\r
88         }\r
89     }\r
90 }\r