[RunInstaller(true)] public partial class Installer1 : Installer { private string dbname; private string dbserver; private string username; private string password; public Installer1() { InitializeComponent(); } public override void Install(IDictionary stateSaver) { dbname = "DevTest"; dbserver = this.Context.Parameters["dbserver"].ToString(); username = this.Context.Parameters["username"].ToString(); password = this.Context.Parameters["password"].ToString(); base.Install(stateSaver); } protected override void OnAfterInstall(IDictionary savedState) { base.OnAfterInstall(savedState); Form1 frm = new Form1(); frm.ShowDialog(); } protected override void OnBeforeInstall(IDictionary savedState) { base.OnBeforeInstall(savedState); } protected override void OnCommitting(IDictionary savedState) { Form1 form1 = new Form1(); if (form1.ShowDialog() == DialogResult.OK) { using (SqlConnection conn = new SqlConnection(form1.ConnString)) { conn.Open(); if (conn.State==ConnectionState.Open) { Form2 frm = new Form2(); frm.ShowDialog(); } } } base.OnCommitting(savedState); } public override void Uninstall(IDictionary savedState) { if (savedState == null) throw new ApplicationException("uninstall error"); else base.Uninstall(savedState); } }
namespace ClassLibrary1 { [RunInstaller(true)] public class Installer : System.Configuration.Install.Installer { public override void Install(IDictionary stateSaver) { base.Install(stateSaver); Form1 hc = new Form1(); MessageBox.Show(this.Context.Parameters["targetdir"].ToString()); hc.ShowDialog(); File.Delete(this.Context.Parameters["targetdir"] + "\\database.sql"); } } }