using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Windows.Forms; namespace Furnace_Setup { static class Program { /// /// The main entry point for the application. /// [STAThread] static void Main() { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new FuranceSetup()); } } public partial class FuranceSetup : ApplicationContext { public FuranceSetup() { var exeFilePath = System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName; exeFilePath = exeFilePath.Substring(0, exeFilePath.LastIndexOf("\\")) + "\\" + "FurnaceSetupPackages.exe"; System.IO.FileInfo fi = new System.IO.FileInfo(exeFilePath); if (fi.Exists) { } else { if (MessageBox.Show(string.Format("当前安装包不包含Furnace配置的安装信息,安装失败!"), "Furnace安装", 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("FurnaceRT") || procList.Contains("FurnaceUI")) { //if (MessageBox.Show(string.Format("检测程序尚在运行,是否使其终止运行!"), "Furnace安装", MessageBoxButtons.OKCancel, // MessageBoxIcon.Error) == DialogResult.OK) //{ // CloseProc("ThermalRT"); // CloseProc("ThermalUI"); // System.Diagnostics.Process.Start(exeFilePath); //} if (MessageBox.Show(string.Format("检测程序尚在运行,安装失败!"), "Furnace安装", MessageBoxButtons.OK, MessageBoxIcon.Error) == DialogResult.OK) { } } else { //if (MessageBox.Show(string.Format("即将运行Thermal安装程序,请确认以下信息是否正确:\n\n程序变更号:{0}\n\n请确认是否继续完成安装?", tmVariation), "Thermal安装", 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; } } }