summaryrefslogtreecommitdiffstats
path: root/win/C#/Functions/System.cs
blob: 83882fe4cc904c16f3db34375b70454e0bd8edf9 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
/*  System.cs $
 	
 	   This file is part of the HandBrake source code.
 	   Homepage: <http://handbrake.fr>.
 	   It may be used under the terms of the GNU General Public License. */

using System;
using System.Windows.Forms;
using Microsoft.Win32;

namespace Handbrake.Functions
{
    class SystemInfo
    {
        /// <summary>
        /// Returns the total physical ram in a system
        /// </summary>
        /// <returns></returns>
        public static uint TotalPhysicalMemory
        {
            get
            {
                Win32.MEMORYSTATUS memStatus = new Win32.MEMORYSTATUS();
                Win32.GlobalMemoryStatus(ref memStatus);

                uint memoryInfo = memStatus.dwTotalPhys;
                memoryInfo = memoryInfo/1024/1024;

                return memoryInfo;
            }
        }

        /// <summary>
        /// Get the number of CPU Cores
        /// </summary>
        /// <returns>Object</returns>
        public static Object GetCpuCount
        {
            get
            {
                RegistryKey regKey = Registry.LocalMachine;
                regKey = regKey.OpenSubKey("HARDWARE\\DESCRIPTION\\System\\CentralProcessor\\0");
                return regKey == null ? 0 : regKey.GetValue("ProcessorNameString");
            }
        }

        /// <summary>
        /// Get the System screen size information.
        /// </summary>
        /// <returns>System.Windows.Forms.Scree</returns>
        public static Screen ScreenBounds
        {
            get { return Screen.PrimaryScreen; }
        }
    }
}