C#判断程序是否运行
 using System;
using System; using System.Collections.Generic;
using System.Collections.Generic; using System.Windows.Forms;
using System.Windows.Forms; using System.Diagnostics;
using System.Diagnostics; using System.Collections;
using System.Collections;
 namespace DataUpper
namespace DataUpper {
{ static class Program
    static class Program {
    { /// <summary>
        /// <summary> /// 应用程序的主入口点。
        /// 应用程序的主入口点。 /// </summary>
        /// </summary> [STAThread]
        [STAThread] static void Main()
        static void Main() {
        { int iProcessNum = 0;
            int iProcessNum = 0;
 foreach (Process singleProc in Process.GetProcesses())
            foreach (Process singleProc in Process.GetProcesses()) {
            { if (singleProc.ProcessName == Process.GetCurrentProcess().ProcessName)
                if (singleProc.ProcessName == Process.GetCurrentProcess().ProcessName) {
                { iProcessNum += 1;
                    iProcessNum += 1; }
                } }
            }
 if (iProcessNum > 1)
            if (iProcessNum > 1) {
            { MessageBox.Show("该程序已经在运行中!", "天科多协议处理子程序", MessageBoxButtons.OK, MessageBoxIcon.Information);
                MessageBox.Show("该程序已经在运行中!", "天科多协议处理子程序", MessageBoxButtons.OK, MessageBoxIcon.Information); }
            } else
            else {
            { Application.EnableVisualStyles();
                Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false);
                Application.SetCompatibleTextRenderingDefault(false); Application.Run(new DataUpper());
                Application.Run(new DataUpper()); }
            } }
        } }
    } }
} 
                     
                    
                 
                    
                 


 
     
                
            
         
         浙公网安备 33010602011771号
浙公网安备 33010602011771号