OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / Functions / System.cs
1 /*  System.cs $\r
2         \r
3            This file is part of the HandBrake source code.\r
4            Homepage: <http://handbrake.fr>.\r
5            It may be used under the terms of the GNU General Public License. */\r
6 \r
7 using System;\r
8 using System.Windows.Forms;\r
9 using Microsoft.Win32;\r
10 \r
11 namespace Handbrake.Functions\r
12 {\r
13     class SystemInfo\r
14     {\r
15         /// <summary>\r
16         /// Returns the total physical ram in a system\r
17         /// </summary>\r
18         /// <returns></returns>\r
19         public static uint TotalPhysicalMemory\r
20         {\r
21             get\r
22             {\r
23                 Win32.MEMORYSTATUS memStatus = new Win32.MEMORYSTATUS();\r
24                 Win32.GlobalMemoryStatus(ref memStatus);\r
25 \r
26                 uint memoryInfo = memStatus.dwTotalPhys;\r
27                 memoryInfo = memoryInfo/1024/1024;\r
28 \r
29                 return memoryInfo;\r
30             }\r
31         }\r
32 \r
33         /// <summary>\r
34         /// Get the number of CPU Cores\r
35         /// </summary>\r
36         /// <returns>Object</returns>\r
37         public static Object GetCpuCount\r
38         {\r
39             get\r
40             {\r
41                 RegistryKey regKey = Registry.LocalMachine;\r
42                 regKey = regKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");\r
43                 return regKey == null ? 0 : regKey.GetValue("ProcessorNameString");\r
44             }\r
45         }\r
46 \r
47         /// <summary>\r
48         /// Get the System screen size information.\r
49         /// </summary>\r
50         /// <returns>System.Windows.Forms.Scree</returns>\r
51         public static Screen ScreenBounds\r
52         {\r
53             get { return Screen.PrimaryScreen; }\r
54         }\r
55     }\r
56 }\r