除了改数据库字段外还有什么方法。尽量在程序中来实现。
注意是WINFORM。谢谢。

解决方案 »

  1.   

    让程序只打开一次:
            [STAThread]
            static void Main()
            {
                System.Threading.Mutex mutex = new System.Threading.Mutex(false, "YouAppName");
                bool Running = !mutex.WaitOne(0, false);
                if (!Running)
                {
                    Application.EnableVisualStyles();
                    Application.SetCompatibleTextRenderingDefault(false);
                    Application.Run(new Form1());
                }
                else
                {
                    MessageBox.Show("应用程序已经启动,请检查窗口是否最小化!", "*****", MessageBoxButtons.OK, MessageBoxIcon.Stop);
                }
            }
      

  2.   

       大家抛玉我来放砖:这个方法即是取得当前程序的运行数~~~
    大于1就退出,否则就运行~简单吧.        [STAThread]
            static void Main()
            {
                Process currentPro = Process.GetCurrentProcess();
                string pron = currentPro.ProcessName;
                Process[] myProcesses = Process.GetProcessesByName(pron);
                if (myProcesses.Length > 1)
                {
                    //可以自定义提示对话框
                    Application.Exit();
                }
                else {
                    (new TongLi()).Show();
                    Application.Run();
                }        }
      

  3.   

    c# winform 防止多重启动,效果 在同一路径下不能多重启动,在不同路径下可以重复启动
    下面代码无法实现 在不同路径下多重启动的要求,哪位高手还有别的方法。
    bool CreateStatus = false;
    string strAppName = string.Empty;
    strAppName = Application.ExecutablePath;Mutex m_Mutex = new Mutex(true, "strAppName", out CreateStatus);
    if (CreateStatus == false)
    {
      MessageBox.Show("不能多重启动");
      return;
    }