Program.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. using Common;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Diagnostics;
  5. using System.Linq;
  6. using System.Reflection;
  7. using System.Threading;
  8. using System.Threading.Tasks;
  9. using System.Windows.Forms;
  10. namespace JC_MeasuringSystem
  11. {
  12. static class Program
  13. {
  14. /// <summary>
  15. /// 应用程序的主入口点。
  16. /// </summary>
  17. [STAThread]
  18. static void Main()
  19. {
  20. bool createNew;
  21. using (System.Threading.Mutex m = new System.Threading.Mutex(true, Application.ProductName, out createNew))
  22. {
  23. Application.EnableVisualStyles();
  24. Application.SetCompatibleTextRenderingDefault(false);
  25. FrmLogin frm = new FrmLogin();
  26. frm.ShowDialog();
  27. if (!string.IsNullOrEmpty(frm.UserInfo.userid))
  28. {
  29. CoreAppUser user = frm.UserInfo;
  30. frm.Dispose();
  31. Application.Run(new ST_MainForm(user));
  32. }
  33. /*
  34. if (createNew)
  35. {
  36. bool ExistsProcess = false;
  37. do
  38. {
  39. ExistsProcess = false;
  40. Process currentProcess = Process.GetCurrentProcess();
  41. foreach (Process process in Process.GetProcessesByName(currentProcess.ProcessName))
  42. {
  43. Thread.Sleep(500);
  44. if ((process.Id != currentProcess.Id) &&
  45. (Assembly.GetExecutingAssembly().Location == currentProcess.MainModule.FileName))
  46. {
  47. ExistsProcess = true;
  48. }
  49. }
  50. } while (ExistsProcess);
  51. Application.EnableVisualStyles();
  52. Application.SetCompatibleTextRenderingDefault(false);
  53. FrmLogin frm = new FrmLogin();
  54. frm.ShowDialog();
  55. if (!string.IsNullOrEmpty(frm.UserInfo.userid))
  56. {
  57. CoreAppUser user = frm.UserInfo;
  58. frm.Dispose();
  59. Application.Run(new ST_MainForm(user));
  60. }
  61. }
  62. else
  63. {
  64. MessageBox.Show("已启动该程序,不允许重复启动!", "错误", MessageBoxButtons.OK, MessageBoxIcon.Error, MessageBoxDefaultButton.Button1, MessageBoxOptions.DefaultDesktopOnly);
  65. }
  66. */
  67. }
  68. }
  69. }
  70. }