1 /// <summary>
2 /// 应用程序的主入口点。
3 /// </summary>
4 [STAThread]
5 static void Main()
6 {
7 #region 判断程序是否已打开
8 int processCount = 0;
9 Process[] pa = Process.GetProcesses();//获取当前进程数组。
10 foreach (Process PTest in pa)
11 {
12 if (PTest.ProcessName == Process.GetCurrentProcess().ProcessName)
13 {
14 processCount += 1;
15 }
16 }
17 if (processCount > 1)
18 {
//非调试状态
19 //如果程序已经运行,则给出提示。并退出本进程。
20 DialogResult dr;
21 //dr = MessageBox.Show(Process.GetCurrentProcess().ProcessName + "程序已经在运行!", "退出程序", MessageBoxButtons.OK, MessageBoxIcon.Error);
22 //可能你不需要弹出窗口,在这里可以屏蔽掉
23
24 return; //Exit;
25
26 }
27 #endregion
28 Application.EnableVisualStyles();
29 Application.SetCompatibleTextRenderingDefault(false);
30 Application.Run(new GITI());
31 }