Program.cs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. using System;
  2. using System.Windows.Forms;
  3. namespace OTSMeasureApp
  4. {
  5. static class Program
  6. {
  7. /// <summary>
  8. /// 应用程序的主入口点。
  9. /// </summary>
  10. [STAThread]
  11. static void Main()
  12. {
  13. //判断是否有授权
  14. //var reg = new CRegistration();
  15. //if (!reg.RegistrationVerification())
  16. //{
  17. // MessageBox.Show("Error: missing authorization");
  18. // System.Environment.Exit(0);
  19. // return;
  20. //}
  21. //--------------------------只运行一个测量程序--------------------------------
  22. bool flag = false;
  23. System.Threading.Mutex mutex = new System.Threading.Mutex(true, "OTSIncAMeasureApp", out flag);
  24. //第一个参数:true--给调用线程赋予互斥体的初始所属权
  25. //第一个参数:互斥体的名称
  26. //第三个参数:返回值,如果调用线程已被授予互斥体的初始所属权,则返回true
  27. if (!flag)
  28. {
  29. MessageBox.Show("Only one measurement program can be run!", "please confirm", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  30. Environment.Exit(0);//退出程序
  31. }
  32. Application.EnableVisualStyles();
  33. Application.SetCompatibleTextRenderingDefault(false);
  34. Application.Run(new OTSIncAMeasureAppForm());
  35. }
  36. }
  37. }