Program.cs 1.2 KB
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace paddleOCR
{
    internal static class Program
    {
        /// <summary>
        /// 应用程序的主入口点。
        /// </summary>
        [STAThread]
        static void Main()
        {
            if (IsRun())
                return;
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);
            Application.Run(new Paddle());
        }
        private static bool IsRun()
        {
            Process current = Process.GetCurrentProcess();
            try
            {
                Process[] processes = Process.GetProcessesByName(current.ProcessName);
                foreach (Process process in processes)
                {
                    if (process.Id == current.Id) continue;  //自己
                    if (process.MainModule.FileName == current.MainModule.FileName)
                        return true;
                }
            }
            catch {
                return true;
            }

            return false;
        }
    }
}