| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647 | using System;using System.Windows.Forms;namespace OTSMeasureApp{    static class Program    {        /// <summary>        /// 应用程序的主入口点。        /// </summary>        [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);//退出程序              }            Application.EnableVisualStyles();            Application.SetCompatibleTextRenderingDefault(false);            Application.Run(new OTSIncAMeasureAppForm());                   }          }}
 |