123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using OTSMeasureApp._10_OTSSplashScreen;
- using System;
- using System.Reflection;
- using System.Windows.Forms;
- namespace OTSMeasureApp
- {
- static class Program
- {
- /// <summary>
- /// 应用程序的主入口点。
- /// </summary>
- static Program()
- {
- string privatepath = "System;Common;DevExpress;FEIAutoScript;SQLiteDll;OxfordExtender;OTSCPPDll;OpenCvSharp;CefSharp";
- AppDomain.CurrentDomain.SetData("PRIVATE_BINPATH", privatepath);
- AppDomain.CurrentDomain.SetData("BINPATH_PROBE_ONLY", privatepath);
- var m = typeof(AppDomainSetup).GetMethod("UpdateContextProperty", BindingFlags.NonPublic | BindingFlags.Static);
- var funsion = typeof(AppDomain).GetMethod("GetFusionContext", BindingFlags.NonPublic | BindingFlags.Instance);
- m.Invoke(null, new object[] { funsion.Invoke(AppDomain.CurrentDomain, null), "PRIVATE_BINPATH", privatepath });
- }
- [STAThread]
- static void Main()
- {
- if (!System.Diagnostics.Debugger.IsAttached)
- {
- //判断是否有授权
- var reg = new CRegistration();
- if (!reg.RegistrationVerification())
- {
- MessageBox.Show("Error: missing authorization");
- System.Environment.Exit(0);
- return;
- }
- }
-
- //--------------------------只运行一个测量程序--------------------------------
- bool flag = false;
- System.Threading.Mutex mutex = new System.Threading.Mutex(true, "OTSIncAMeasureApp", out flag);
- //第一个参数:true--给调用线程赋予互斥体的初始所属权
- //第一个参数:互斥体的名称
- //第三个参数:返回值,如果调用线程已被授予互斥体的初始所属权,则返回true
- if (!flag)
- {
- MessageBox.Show("Only one measurement program can be run!", "please confirm", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
- Environment.Exit(0);//退出程序
- }
- //AppDomain.CurrentDomain.AssemblyResolve += CurrentDomain_AssemblyResolve;
- Application.EnableVisualStyles();
- Application.SetCompatibleTextRenderingDefault(false);
- //OTSSplashScreen_IncA sp = new OTSSplashScreen_IncA();
- //sp.Show();
- //var f = ;
- //f.sp = sp;
- Application.Run(new OTSIncAMeasureAppForm());
-
- }
-
- }
- }
|