让程序只能运行一次
2013-09-29 15:58
176 查看
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
namespace frameTest
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
string MName = Process.GetCurrentProcess().MainModule.ModuleName;
string PName = Path.GetFileNameWithoutExtension(MName);
Process[] myProccess = Process.GetProcessesByName(PName);
if (myProccess.Length > 1)
{
MessageBox.Show("程序已经运行,不能重复打开", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
}
using System.Collections.Generic;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
namespace frameTest
{
static class Program
{
/// <summary>
/// 应用程序的主入口点。
/// </summary>
[STAThread]
static void Main()
{
string MName = Process.GetCurrentProcess().MainModule.ModuleName;
string PName = Path.GetFileNameWithoutExtension(MName);
Process[] myProccess = Process.GetProcessesByName(PName);
if (myProccess.Length > 1)
{
MessageBox.Show("程序已经运行,不能重复打开", "友情提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
else
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
}
}
相关文章推荐
- VC++ 一次只能运行一个程序设置
- 用"互斥"让程序只能运行一次
- wince c# 程序只能运行一次
- c# 程序只能运行一次
- c# 程序只能运行一次(多次运行只能打开同一个程序)
- PyQt4在spyder中使用,程序只能运行一次,第二次运行报错:It seems the kernel died unexpectedly. Use 'Restart kernel' to cont
- 怎样让VB6程序只能运行一次
- c# 程序只能运行一次(多次运行只能打开同一个程序) 并激活第一个实例,使其获得焦点,并在最前端显示.
- c# 程序只能运行一次(多次运行只能打开同一个程序) 并激活第一个实例,使其获得焦点,并在最前端显示.
- 让程序 只能运行一次
- 让程序只能运行一次
- .Net中如何限制执行程序只能运行一次和如何读写注册表
- 使程序只能运行一次,用互斥量来判断程序是否已运行,并设置窗体背景色
- wince c# 程序只能运行一次
- c# 程序只能运行一次(多次运行只能打开同一个程序) 并激活第一个实例,使其获得焦点,并在最前端显示.
- 程序只能运行一次
- wince c# 程序只能运行一次
- 程序只能运行一次
- C语言实现的一个程序只能运行一次,不能重复运行
- WinCE下面运行程序时只能运行一次的方法