Program.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using OTSMeasureApp._10_OTSSplashScreen;
  2. using System;
  3. using System.Reflection;
  4. using System.Windows.Forms;
  5. namespace OTSMeasureApp
  6. {
  7. static class Program
  8. {
  9. /// <summary>
  10. /// 应用程序的主入口点。
  11. /// </summary>
  12. static Program()
  13. {
  14. string privatepath = "System;Common;DevExpress;FEIAutoScript;SQLiteDll;OxfordExtender;OTSCPPDll;OpenCvSharp;CefSharp";
  15. AppDomain.CurrentDomain.SetData("PRIVATE_BINPATH", privatepath);
  16. AppDomain.CurrentDomain.SetData("BINPATH_PROBE_ONLY", privatepath);
  17. var m = typeof(AppDomainSetup).GetMethod("UpdateContextProperty", BindingFlags.NonPublic | BindingFlags.Static);
  18. var funsion = typeof(AppDomain).GetMethod("GetFusionContext", BindingFlags.NonPublic | BindingFlags.Instance);
  19. m.Invoke(null, new object[] { funsion.Invoke(AppDomain.CurrentDomain, null), "PRIVATE_BINPATH", privatepath });
  20. }
  21. [STAThread]
  22. static void Main()
  23. {
  24. if (!System.Diagnostics.Debugger.IsAttached)
  25. {
  26. //判断是否有授权
  27. var reg = new CRegistration();
  28. if (!reg.RegistrationVerification())
  29. {
  30. MessageBox.Show("Error: missing authorization");
  31. System.Environment.Exit(0);
  32. return;
  33. }
  34. }
  35. //--------------------------只运行一个测量程序--------------------------------
  36. bool flag = false;
  37. System.Threading.Mutex mutex = new System.Threading.Mutex(true, "OTSIncAMeasureApp", out flag);
  38. //第一个参数:true--给调用线程赋予互斥体的初始所属权
  39. //第一个参数:互斥体的名称
  40. //第三个参数:返回值,如果调用线程已被授予互斥体的初始所属权,则返回true
  41. if (!flag)
  42. {
  43. MessageBox.Show("Only one measurement program can be run!", "please confirm", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
  44. Environment.Exit(0);//退出程序
  45. }
  46. //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
  47. Application.EnableVisualStyles();
  48. Application.SetCompatibleTextRenderingDefault(false);
  49. //OTSSplashScreen_IncA sp = new OTSSplashScreen_IncA();
  50. //sp.Show();
  51. //var f = ;
  52. //f.sp = sp;
  53. Application.Run(new OTSIncAMeasureAppForm());
  54. }
  55. }
  56. }