OSDN Git Service

Change the fifo size from being statically tuned for a Mac Pro with 4 CPUs to dynamic...
[handbrake-jp/handbrake-jp-git.git] / win / C# / Program.cs
1 using System;\r
2 using System.Collections.Generic;\r
3 using System.Collections.Specialized;\r
4 using System.ComponentModel;\r
5 using System.Data;\r
6 using System.Drawing;\r
7 using System.Text;\r
8 using System.Windows.Forms;\r
9 using System.Net;\r
10 using System.IO;\r
11 using System.Diagnostics;\r
12 using System.Threading;\r
13 using System.Runtime.InteropServices;\r
14 \r
15 \r
16 namespace Handbrake\r
17 {\r
18     static class Program\r
19     {\r
20         /// <summary>\r
21         /// The main entry point for the application.\r
22         /// </summary>\r
23         [STAThread]\r
24         static void Main()\r
25         {\r
26             // 633265950858281250 = 16:52 28-Sep-07  //864000000000 nanoseconds per day\r
27             //long start = DateTime.Now.Ticks;\r
28             //if (start > 633274593039531250) {MessageBox.Show("Sorry, This development build of Handbrake has expired."); return; } // Will Expire Oct 8th\r
29 \r
30             // Check the system meets the system requirements.\r
31             Boolean launch = true;\r
32             try\r
33             {\r
34                 // Make sure the screen resolution is not below 1024x768\r
35                 System.Windows.Forms.Screen scr = System.Windows.Forms.Screen.PrimaryScreen;\r
36                 if ((scr.Bounds.Width < 1024) || (scr.Bounds.Height < 768))\r
37                 {\r
38                     MessageBox.Show("Your system does not meet the minimum requirements for HandBrake. \n Screen resolution is too Low. Must be 1024x768 or greater", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
39                     launch = false;\r
40                 }\r
41 \r
42                 // Make sure the system has enough RAM. 384MB or greater\r
43                 uint memory = MemoryCheck.CheckMemeory();\r
44 \r
45                 if (memory < 319) // Set to 319 to allow for 64MB dedicated to video Memory and Windows returnig the memory figure slightly out.\r
46                 {\r
47                     MessageBox.Show("Your system does not meet the minimum requirements for HandBrake. \n Insufficient Memory. 384MB or greater required.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
48                     launch = false;\r
49                 }\r
50             }\r
51             catch (Exception exc)\r
52             {\r
53                 if (Properties.Settings.Default.GuiDebug == "Checked")\r
54                 {\r
55                     MessageBox.Show("frmMain.cs - systemCheck() " + exc.ToString());\r
56                 }\r
57             }\r
58 \r
59 \r
60             // Either Launch or Close the Application\r
61             if (launch == true)\r
62             {\r
63                 Application.EnableVisualStyles();\r
64                 Application.SetCompatibleTextRenderingDefault(false);\r
65                 Application.Run(new frmMain());\r
66             }\r
67             else\r
68             {\r
69                 Application.Exit();\r
70             }\r
71         }\r
72     }\r
73 \r
74     class MemoryCheck\r
75     {\r
76         public struct MEMORYSTATUS\r
77         {\r
78             public UInt32 dwLength;\r
79             public UInt32 dwMemoryLoad;\r
80             public UInt32 dwTotalPhys; // Used\r
81             public UInt32 dwAvailPhys;\r
82             public UInt32 dwTotalPageFile;\r
83             public UInt32 dwAvailPageFile;\r
84             public UInt32 dwTotalVirtual;\r
85             public UInt32 dwAvailVirtual;\r
86             // Aditional Varibles left in for future usage (JIC)\r
87         }\r
88 \r
89         [DllImport("kernel32.dll")]\r
90         public static extern void GlobalMemoryStatus\r
91         (\r
92             ref MEMORYSTATUS lpBuffer\r
93         );\r
94 \r
95         public static uint CheckMemeory()\r
96         {\r
97             // Call the native GlobalMemoryStatus method\r
98             // with the defined structure.\r
99             MEMORYSTATUS memStatus = new MEMORYSTATUS();\r
100             GlobalMemoryStatus(ref memStatus);\r
101 \r
102             uint MemoryInfo = memStatus.dwTotalPhys;\r
103 \r
104             return MemoryInfo;\r
105         }\r
106     }\r
107 }