using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows.Forms;
using System.Diagnostics;
using System.Reflection;
using ICSSoft.Base.Language.Tool;
using ICSSoft.Base.UserControl.MessageControl;
namespace ICSSoft.Frame.Main.Entrance
{
static class Program
{
public static System.Threading.Mutex Run;
///
/// 应用程序的主入口点。
///
[STAThread]
static void Main()
{
bool noRun = false;
Run = new System.Threading.Mutex(true, Application.ProductName, out noRun);
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
System.Threading.Thread.CurrentThread.CurrentUICulture = new System.Globalization.CultureInfo("zh-CN");
var res=DevExpress.Skins.SkinManager.Default.RegisterAssembly(typeof(DevExpress.UserSkins.SelfSkin).Assembly);
if (noRun)
{
//未运行
Run.ReleaseMutex();
Application.Run(new FormLoginNew());
}
else
{
List langList = new List();
LangObj obj = new LangObj();
obj.LConvertString = "该系统已经有一个实例在运行,无法再次运行!";
obj.LParameters = new object[] { };
langList.Add(obj);
MessageDialog dialog = new MessageDialog(1, langList);
dialog.ShowDialog();
}
}
private static Process RuningInstance()
{
Process currentProcess = Process.GetCurrentProcess();
Process[] Processes = Process.GetProcessesByName(currentProcess.ProcessName);
foreach (Process process in Processes)
{
if (process.Id != currentProcess.Id)
{
if (Assembly.GetExecutingAssembly().Location.Replace("/", "\\") == currentProcess.MainModule.FileName)
{
return process;
}
}
}
return null;
}
}
}