| 123456789101112131415161718192021222324252627282930313233 | using System;using System.Windows.Forms;namespace OTSMeasureApp{    static class Program    {        /// <summary>        /// 应用程序的主入口点。        /// </summary>        [STAThread]        static void Main()        {            //--------------------------只运行一个测量程序--------------------------------            bool flag = false;            System.Threading.Mutex mutex = new System.Threading.Mutex(true, "OTSIncAMeasureApp", out flag);            //第一个参数:true--给调用线程赋予互斥体的初始所属权              //第一个参数:互斥体的名称              //第三个参数:返回值,如果调用线程已被授予互斥体的初始所属权,则返回true              if (!flag)            {                MessageBox.Show("只能运行一个测量程序!", "请确定", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);                Environment.Exit(0);//退出程序              }            Application.EnableVisualStyles();            Application.SetCompatibleTextRenderingDefault(false);            Application.Run(new OTSIncAMeasureAppForm());        }    }}
 |