可以.
以下是应用程序启动函数(Main):
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); // 保证只能有一个进程运行.
bool isRun = true;
Process cp = Process.GetCurrentProcess();
Process[] p = Process.GetProcesses();
for (int i = 0; i < p.Length; i++)
{
if (p[i].ProcessName == cp.ProcessName)
{
isRun = false;
}
}
// 如果找到说明正在运行
if (isRun)
{
MessageBox.Show("程序已运行...", "XX系统"
, MessageBoxButtons.OK, MessageBoxIcon.Warning);
Application.Exit();
}
else
{
Application.Run(new LoginForm());
}
}
以下是应用程序启动函数(Main):
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false); // 保证只能有一个进程运行.
bool isRun = true;
Process cp = Process.GetCurrentProcess();
Process[] p = Process.GetProcesses();
for (int i = 0; i < p.Length; i++)
{
if (p[i].ProcessName == cp.ProcessName)
{
isRun = false;
}
}
// 如果找到说明正在运行
if (isRun)
{
MessageBox.Show("程序已运行...", "XX系统"
, MessageBoxButtons.OK, MessageBoxIcon.Warning);
Application.Exit();
}
else
{
Application.Run(new LoginForm());
}
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货