OSDN Git Service

WinGui:
[handbrake-jp/handbrake-jp-git.git] / win / C# / Functions / System.cs
1 /*  System.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 namespace Handbrake.Functions\r
7 {\r
8     using System.Windows.Forms;\r
9     using Microsoft.Win32;\r
10 \r
11     /// <summary>\r
12     /// The System Information.\r
13     /// </summary>\r
14     public class SystemInfo\r
15     {\r
16         /// <summary>\r
17         /// Gets the total physical ram in a system\r
18         /// </summary>\r
19         /// <returns>The total memory in the system</returns>\r
20         public static uint TotalPhysicalMemory\r
21         {\r
22             get\r
23             {\r
24                 Win32.MEMORYSTATUS memStatus = new Win32.MEMORYSTATUS();\r
25                 Win32.GlobalMemoryStatus(ref memStatus);\r
26 \r
27                 uint memoryInfo = memStatus.dwTotalPhys;\r
28                 memoryInfo = memoryInfo / 1024 / 1024;\r
29 \r
30                 return memoryInfo;\r
31             }\r
32         }\r
33 \r
34         /// <summary>\r
35         /// Gets the number of CPU Cores\r
36         /// </summary>\r
37         /// <returns>Object</returns>\r
38         public static object GetCpuCount\r
39         {\r
40             get\r
41             {\r
42                 RegistryKey regKey = Registry.LocalMachine;\r
43                 regKey = regKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");\r
44                 return regKey == null ? 0 : regKey.GetValue("ProcessorNameString");\r
45             }\r
46         }\r
47 \r
48         /// <summary>\r
49         /// Gets the System screen size information.\r
50         /// </summary>\r
51         /// <returns>System.Windows.Forms.Scree</returns>\r
52         public static Screen ScreenBounds\r
53         {\r
54             get { return Screen.PrimaryScreen; }\r
55         }\r
56     }\r
57 }