コード例 #1
0
ファイル: Main.cs プロジェクト: 6555355/Scan_yan1
        static void Main(string[] args)
        {
#if EpsonLcd
            bool showUI = true;
            try
            {
                if (args != null && args.Length > 0)
                {
                    showUI = bool.Parse(args[0]);
                }
            }
            catch
            {
//				showUI = false;
            }
#endif
            // enable XP theme support
            Application.EnableVisualStyles();
            Application.DoEvents();

            //SetLanguage();
            //Chinese XP system
            if (((System.Globalization.CultureInfo.InstalledUICulture.LCID & 0xff) == 04) &&
                System.Environment.OSVersion.Version.Major == 5 &&
                System.Environment.OSVersion.Version.Minor == 1)
            {
                string filename = System.Environment.SystemDirectory + Path.DirectorySeparatorChar
                                  + "conime.exe";
                if (File.Exists(filename))
                {
                    System.Diagnostics.ProcessStartInfo Info = new  System.Diagnostics.ProcessStartInfo();
                    Info.FileName = filename;

                    System.Diagnostics.Process Proc;
                    try
                    {
                        Proc = System.Diagnostics.Process.Start(Info);
                    }
                    catch                    //(System.ComponentModel.Win32Exception  e)
                    {
                        return;
                    }
                    //等待3秒钟
                    //Proc.WaitForExit(3000);
                }
            }

            const string MUTEX      = CoreConst.c_MUTEX_App;
            bool         createdNew = false;
            Mutex        mutex      = new Mutex(true, MUTEX, out createdNew);
            if (!createdNew)
            {
#if EpsonLcd
                Process process = RuningInstance();
                MyData  data    = ProcessMessaging.GetShareMem(); //您new一个也行
                data.InfoCode  = showUI?1:0;                      //消息码
                data.ProcessID = process.Id;                      //接收进程ID
                ProcessMessaging.SetShareMem(data);
                Thread.Sleep(100);
                return;
#else
                MessageBox.Show(ResString.GetEnumDisplayName(typeof(UIError), UIError.OnlyOneProgram));
                mutex.Close();
                return;
#endif
            }

#if EpsonLcd
            int lcid = PubFunc.GetLanguage();
            if (lcid == -1)
            {
                // 未连接usb线,无法获取软件语言,启动终止.
                MessageBox.Show(ResString.GetResString("NoFoundUSBReturn"), ResString.GetProductName(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }
#else
            AllParam cur  = new AllParam();
            int      lcid = cur.GetLanguage();
#endif

            Thread.CurrentThread.CurrentCulture   = new CultureInfo("en-US");
            Thread.CurrentThread.CurrentUICulture = new CultureInfo(lcid);

            bool splashEnable = PubFunc.GetEnableSplash();
            if (splashEnable)
            {
                Splasher.ShowSplash(1000);
            }

            string skinName = cur.GetSkinName();

#if EpsonLcd
            MainForm mainWin = new MainForm(showUI);
#else
            MainForm mainWin = new MainForm(true, skinName);
#endif
            Application.AddMessageFilter(mainWin);
            if (mainWin.Start())
            {
                Application.Run(mainWin);
            }
            mutex.Close();
        }