好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

C#简单实现防止多个程序运行的方法

本文实例讲述了C#简单实现防止多个程序运行的方法。分享给大家供大家参考,具体如下:

?

/// <summary>

/// 应用程序的主入口点。

/// </summary>

[STAThread]

static void Main()

{

   System.Diagnostics.Process[] ps = System.Diagnostics.Process.GetProcessesByName(System.Diagnostics.Process.GetCurrentProcess().ProcessName);

   if (ps.Length <= 1)

   {

     Application.EnableVisualStyles();

     Application.SetCompatibleTextRenderingDefault( false );

     Application.Run( new MainForm());

   }

   else

   {

     return ;

   }

}

希望本文所述对大家C#程序设计有所帮助。

dy("nrwz");

查看更多关于C#简单实现防止多个程序运行的方法的详细内容...

  阅读:53次