欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

wpf单例及带参数调用

程序员文章站 2022-07-13 22:23:28
...
using System;
using System.Collections.Generic;
using System.Configuration;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.Windows;

namespace FM
{
    /// <summary>
    /// App.xaml 的交互逻辑
    /// </summary>
    public partial class App : Application
    {
        protected override void OnStartup(StartupEventArgs e)
        {
            Process process = Process.GetCurrentProcess();
            foreach (Process p in Process.GetProcessesByName(process.ProcessName))
            {
                if (p.Id != process.Id)
                {
                    MessageBox.Show("您的程序已经启动");
                    Application.Current.Shutdown();
                    return;
                }
            }



            base.OnStartup(e);

            if (e.Args.Length == 2)
            {
                Arg.ThisWbName = e.Args[0];
                Arg.ThisShtName = e.Args[1];
            }
            //foreach (var item in e.Args)
            //{
            //    MessageBox.Show(item);
            //}


        }
    }

    public class Arg
    {
        public static string ThisWbName { get; set; }
        public static string ThisShtName { get; set; }
    }
}

 

相关标签: C#