http://expert.csdn.net/Expert/TopicView1.asp?id=2572209

解决方案 »

  1.   

    public static bool IsFirst(string appId) 

    bool ret=false; 
    if(OpenMutex(0x1F0001,0,appId)==IntPtr.Zero) 

    CreateMutex(IntPtr.Zero,0,appId); 
    ret=true; 

    return ret; 
    }  [DllImport("Kernel32.dll",CharSet=CharSet.Auto)] 
    private static extern IntPtr OpenMutex( 
    uint dwDesiredAccess,  // access 
    int bInheritHandle,    // inheritance option 
    string lpName          // object name 
    );  [DllImport("Kernel32.dll",CharSet=CharSet.Auto)] 
    private static extern IntPtr CreateMutex( 
    IntPtr lpMutexAttributes,  // SD 
    int bInitialOwner,                       // initial owner 
    string lpName                            // object name 
    );
      

  2.   

    楼主可以看看这个
    http://dotnet.aspx.cc/ShowDetail.aspx?id=E2A17727-765F-4346-8446-5D130622CB54
      

  3.   

    可以参考:
    http://dotnet.aspx.cc/ShowDetail.aspx?id=E2A17727-765F-4346-8446-5D130622CB54
      

  4.   

    在main过程中加入
    Process instance = RunningInstance();
    if (instance == null)
    {
       Application.Run(New MainForm());
    }
    else
    {
       MessageBox.Show("程序已经运行");
    }
      

  5.   

    private void Form1_Load(object sender, System.EventArgs e)
    {
    string Path=Application.ExecutablePath;
    FileInfo aFile=new FileInfo(Path);
    string FileName=aFile.Name;
    FileName=FileName.Substring(0,FileName.Length-4);
    Process[] aPro=Process.GetProcessesByName(FileName);
    if(aPro.Length>1)
    {
    MessageBox.Show("已经有.");
    Application.Exit();
    }