OSDN Git Service

LinGui: tidy up the video, audio, and advanced tabs
[handbrake-jp/handbrake-jp-git.git] / win / C# / Functions / SystemInfo.cs
1 using System;\r
2 using System.Runtime.InteropServices;\r
3 using Microsoft.Win32;\r
4 \r
5 namespace Handbrake.Functions\r
6 {\r
7     class SystemInfo\r
8     {\r
9         #region CheckRam\r
10         private struct MEMORYSTATUS\r
11         {\r
12             public UInt32 dwLength;\r
13             public UInt32 dwMemoryLoad;\r
14             public UInt32 dwTotalPhys; // Used\r
15             public UInt32 dwAvailPhys;\r
16             public UInt32 dwTotalPageFile;\r
17             public UInt32 dwAvailPageFile;\r
18             public UInt32 dwTotalVirtual;\r
19             public UInt32 dwAvailVirtual;\r
20         }\r
21 \r
22         [DllImport("kernel32.dll")]\r
23         private static extern void GlobalMemoryStatus\r
24         (\r
25             ref MEMORYSTATUS lpBuffer\r
26         );\r
27 \r
28 \r
29         /// <summary>\r
30         /// Returns the total physical ram in a system\r
31         /// </summary>\r
32         /// <returns></returns>\r
33         public uint TotalPhysicalMemory()\r
34         {\r
35             MEMORYSTATUS memStatus = new MEMORYSTATUS();\r
36             GlobalMemoryStatus(ref memStatus);\r
37 \r
38             uint MemoryInfo = memStatus.dwTotalPhys;\r
39             MemoryInfo = MemoryInfo / 1024 / 1024; \r
40 \r
41             return MemoryInfo;\r
42         }\r
43         #endregion\r
44 \r
45         public Object getCpuCount()\r
46         {\r
47             RegistryKey RegKey = Registry.LocalMachine;\r
48             RegKey = RegKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");\r
49             return RegKey.GetValue("ProcessorNameString");\r
50         }\r
51 \r
52         public System.Windows.Forms.Screen screenBounds()\r
53         {\r
54             return System.Windows.Forms.Screen.PrimaryScreen;\r
55         }\r
56     }\r
57 }\r