using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; namespace EfemDual_Setup { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new EfemDualSetup()); } } public partial class EfemDualSetup : ApplicationContext { public EfemDualSetup() { var exeFilePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; exeFilePath = exeFilePath.Substring(0, exeFilePath.LastIndexOf("\\")) + "\\" + "EfemDualSetupPackages.exe"; System.IO.FileInfo fi = new System.IO.FileInfo(exeFilePath); if (fi.Exists) { } else { if (MessageBox.Show(string.Format("当前安装包不包含EfemDual配置的安装信息,安装失败!"), "EfemDual安装", MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK) { Environment.Exit(0); } } System.Collections.ArrayList procList = new System.Collections.ArrayList(); foreach (System.Diagnostics.Process thisProc in System.Diagnostics.Process.GetProcesses()) { procList.Add(thisProc.ProcessName); } if (procList.Contains("EfemDualRT") || procList.Contains("EfemDualUI")) { //if (MessageBox.Show(string.Format("检测程序尚在运行,是否使其终止运行!"), "EfemDual安装", MessageBoxButtons.OKCancel, // MessageBoxIcon.Error) == DialogResult.OK) //{ // CloseProc("EfemDualRT"); // CloseProc("EfemDualUI"); // System.Diagnostics.Process.Start(exeFilePath); //} if (MessageBox.Show(string.Format("检测程序尚在运行,安装失败!"), "EfemDual安装", MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK) { } } else { //if (MessageBox.Show(string.Format("即将运行EfemDual安装程序,请确认以下信息是否正确:\n\n程序变更号:{0}\n\n请确认是否继续完成安装?", tmVariation), "EfemDual安装", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) System.Diagnostics.Process.Start(exeFilePath); } Environment.Exit(0); } private bool CloseProc(string procName) { bool result = false; foreach (System.Diagnostics.Process thisProc in System.Diagnostics.Process.GetProcesses()) { if (thisProc.ProcessName == procName) { // if (!thisProc.CloseMainWindow()) thisProc.Kill(); //当发送关闭窗口命令无效时强行结束进程 result = true; } } return result; } } }