Newer
Older
RbFreqStand / RbFreqStandMeasure / Program.cs
yangqianqian on 30 Apr 2021 1 KB 4.30
using System;
using System.Diagnostics;
using System.Windows.Forms;

namespace Casic.Birmm.RbFreqStandMeasure
{
    static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            // Application.Run(new RbFreqStandMeasureForm());

            if (IsRunning())
            {
                MessageBox.Show("铷原子频标比对测量软件已运行!", "提示");
                return;
            }
            Application.Run(new RbFreqStdMeas());
        }

        public static bool IsRunning()
        {
            Process current = default(Process);
            current = System.Diagnostics.Process.GetCurrentProcess();
            Process[] processes = null;
            processes = System.Diagnostics.Process.GetProcessesByName(current.ProcessName);

            Process process = default(Process);

            foreach (Process tempLoopVar_process in processes)
            {
                process = tempLoopVar_process;

                if (process.Id != current.Id)
                {
                    if (System.Reflection.Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == current.MainModule.FileName)
                    {
                        return true;

                    }

                }
            }
            return false;

        }
    }
}