.net 控制只允许运行一个应用程序

Process[] p = Process.GetProcesses();
            int processCount = 0;
            foreach (Process p1 in p)
            {

                if (p1.ProcessName.Trim() == "程序名")               

      {
                    processCount = processCount + 1;
                }
            }
            if (processCount > 1)
            {
                MessageBox.Show("程序已启动");
                Application.Exit();
                return;
            }

posted @ 2011-03-09 15:39  柠檬绿松  阅读(297)  评论(0编辑  收藏  举报
View Code