static void Main() 
{
/*判断程序是否运行*/
bool pblnGotOwnership = false;
Mutex pobjMyMutex = null;
try
{
pobjMyMutex = new Mutex(true, "Application name and/or unique mutex key", out pblnGotOwnership);
if (pblnGotOwnership)
Application.Run(new frmMain());

else
System.Windows.Forms.MessageBox.Show("系统已经运行","系统提示");
}
finally
{
if (pobjMyMutex != null)
pobjMyMutex.Close();
}
}

解决方案 »

  1.   

    yun
    static void Main() 
    {
      /*判断程序是否运行*/
      bool pblnGotOwnership = false;
      Mutex pobjMyMutex = null;
      try
      {
         pobjMyMutex = new Mutex(true, "Application name and/or unique   mutex key", out pblnGotOwnership);
         if (pblnGotOwnership)
           Application.Run(new frmMain());
         else
    System.Windows.Forms.MessageBox.Show("系统已经运行","系统提示");
      }
      finally
      {
      if (pobjMyMutex != null)
        pobjMyMutex.Close();
    }
    }
      

  2.   

    to ninglng(甯灵) 好像不行,解释一下。
      

  3.   

    我就是这么用的阿!可以的需要添加:using System.Threading;form 的TopMost属性是设置该窗体是否在所有其他非最顶部窗体之上
    分啊?
      

  4.   

    /*判断程序是否已经运行*/
    bool pblnGotOwnership = false;
    Mutex pobjMyMutex = null;
    try
    {
    pobjMyMutex = new Mutex(true, "Application name and/or unique mutex key", out pblnGotOwnership);
    if (pblnGotOwnership)
    Application.Run(new frmMain());
    else
    System.Windows.Forms.MessageBox.Show("系统已经运行","系统提示");
    frmMain.
    }
    finallyif (pobjMyMutex != null)
    pobjMyMutex.Close();其中frmMain是你的主窗体将上面的代码添加到
    /// <summary>
    /// 应用程序的主入口点。
    /// </summary>
    [STAThread]
    static void Main() 

      

  5.   

    to ninglng(甯灵) 是我没说清楚了:  判断程序运行否我已经做到了,但我的程序最小化后只在任务栏里有一个图标,双击图标时:
    private void notifyIcon_DoubleClick(object sender, System.EventArgs e)
         {
    if(this.Visible == false)  //显示主界面
    {
    this.Visible =true;
    this.WindowState=FormWindowState.Normal; }

         }但在static void Main() 怎样实现?
      

  6.   

    http://www.csdn.net/expert/topic/997/997785.xml?temp=.6350824是呀,还没成功呢. 不会无法实现吧!!!!!!微软的人到哪里去了?!!!难道你们自己也不会?
      

  7.   

    .Net进程间通信问题...不知道哪有资料